Skip to content

Fix RagService initialization crash, race conditions, and blocking API calls#688

Open
Siddhant2713 wants to merge 3 commits into
viru0909-dev:mainfrom
Siddhant2713:main
Open

Fix RagService initialization crash, race conditions, and blocking API calls#688
Siddhant2713 wants to merge 3 commits into
viru0909-dev:mainfrom
Siddhant2713:main

Conversation

@Siddhant2713
Copy link
Copy Markdown

Summary

This PR fixes multiple stability and reliability issues affecting VakilFriendService, particularly startup failures and request handling problems observed in Docker/local deployments.

Issues Fixed

1. RagService causing VakilFriendService startup failure

  • resource.getFile() fails inside Spring Boot fat JAR deployments.
  • AllMiniLmL6V2EmbeddingModel() loads a large ONNX model causing memory pressure in constrained containers.
  • Because VakilFriendService depends directly on RagService, initialization failure propagates and breaks all /api/vakil-friend/* endpoints.

2. Session initialization race condition

  • sendMessage() only checked isLoading.
  • Requests could be triggered before startSession() completed.
  • Added proper startup-state guarding to prevent premature requests.

3. Raw axios usage without timeout/interceptors

  • Chat requests bypassed the configured API client instance.
  • Requests had no timeout handling and skipped auth interceptors.
  • Replaced raw axios usage with the configured API instance.

4. Blocking RestTemplate calls

  • Multiple services instantiated new RestTemplate() with default infinite timeouts.
  • Long Groq response times blocked Tomcat worker threads.
  • Improved timeout handling and request behavior.

Root Cause Analysis

The primary failure was caused by RagService initialization during application startup.
This issue reproduces locally in Docker, confirming the problem is not related to Render cold starts.

Impact

  • Prevents VakilFriend startup crashes
  • Improves resilience in low-memory environments
  • Prevents premature API calls during session creation
  • Reduces request hanging and thread blocking
  • Improves overall service stability

Testing

  • Reproduced failures locally using Docker setup
  • Verified VakilFriend endpoints initialize successfully
  • Confirmed chat requests no longer hang indefinitely
  • Verified session flow works correctly during startup

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@Siddhant2713 is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant