fix: clean up long-poll listener and timer on client disconnect - #305
Open
birme wants to merge 1 commit into
Open
fix: clean up long-poll listener and timer on client disconnect#305birme wants to merge 1 commit into
birme wants to merge 1 commit into
Conversation
Register a request close handler on the participants long-poll endpoint so the transient 'users:change' listener and its 25s timeout are released when a client disconnects mid-poll, instead of lingering until timeout. A guard boolean ensures cleanup runs exactly once across the change, timeout, and close exit paths so the promise never resolves twice. Also disable maxListeners on the ProductionManager EventEmitter to avoid spurious MaxListenersExceededWarning under >10 concurrent pollers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
request.raw.on('close', ...)cleanup handler to the/production/:productionId/line/:lineId/participantslong-poll endpoint so the transientusers:changelistener and its 25ssetTimeoutare released immediately when a client disconnects mid-poll, rather than lingering until the timeout fires.users:changefires, timeout expires, client closes) through a singlecleanup()guarded by asettledboolean, guaranteeing symmetric listener/timer removal and preventing double-resolve.productionManager.setMaxListeners(0)in theProductionManagerconstructor to suppress spuriousMaxListenersExceededWarningunder >10 concurrent pollers.Test plan
npm test) — 243/243npm run typecheck)npm run lint) — 0 errorsoff('users:change', ...)is called on the change exit pathCloses #291
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com