fix: WHIP/WHEP inactive status, CouchDB resilience, and CORS centralization#194
Merged
fix: WHIP/WHEP inactive status, CouchDB resilience, and CORS centralization#194
Conversation
Both participant API endpoints were overriding isActive to always return true for WHIP/WHEP sessions, preventing them from ever appearing as inactive in the frontend. Sessions would jump straight from active to gone when they expired. Now the actual DB value is passed through so the frontend can show the inactive state. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The existing insertWithRetry only covered insert operations. Transient network errors (ECONNRESET, socket hang up) on any CouchDB call would still crash the process. This adds: - withRetry() wrapper around ALL nano DB operations (get, list, insert, destroy) with exponential backoff (3 retries, 100/200/400ms) - isTransientError() detection for ECONNRESET, ETIMEDOUT, socket hang up, and EHOSTUNREACH - Connection retry with backoff (5 attempts) in connect() - 10s request timeout in nano client config - process.exit(1) in uncaughtException handler to ensure clean restart instead of zombie process - 360 lines of new CouchDB tests covering retry behavior Fixes the recurring pod restarts (146+ on intercomprod) caused by unhandled socket hang up errors from intermediate network components. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Move wildcard CORS from per-route onSend hooks in api_whip.ts and api_whep.ts to a centralized delegator in the @fastify/cors plugin. WHIP/WHEP routes get origin: '*', everything else uses CORS_ORIGIN. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Third location where isActive was forced to true for WHIP sessions, in the getUsersForLine response mapping. Also adds production manager resilience tests for session lifecycle edge cases. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three related issues with WHIP/WHEP session management and CouchDB stability:
api_productions.tsx2,production_manager.tsx1) forcedisActive: truefor WHIP sessions, so they'd jump straight from active to gone when expired. Now passes through the actual DB value.withRetry()wrapper around ALL nano DB operations with exponential backoff, connection retry (5 attempts), and 10s request timeout.onSendhooks inapi_whip.ts/api_whep.tsto a centralizeddelegatorin the@fastify/corsplugin. WHIP/WHEP routes getorigin: '*', everything else usesCORS_ORIGIN.Changes
src/db/couchdb.tswithRetry<T>()— generic retry wrapper for all DB operations (3 retries, 100/200/400ms backoff)isTransientError()— detects ECONNRESET, ETIMEDOUT, socket hang up, EHOSTUNREACHconnect()— retry with backoff (5 attempts, 1/2/4/8/16s)getNextSequence(no longer swallows non-404 errors)src/db/couchdb.test.tssrc/server.tsprocess.exit(1)in uncaughtException handler for clean pod restartsrc/api_productions.tsisActive: s.isWhip ? true : ...→isActive: !!s.isActivesrc/production_manager.tsisWhipoverride removedsrc/api.tsorigin: '*', all other routes useCORS_ORIGINsrc/api_whip.ts/src/api_whep.tsonSendCORS hooksTest plan
Access-Control-Allow-Origin: *CORS_ORIGIN🤖 Generated with Claude Code