Repository navigation
fix(api): stop crawl-status WS polling on client disconnect - #4261
Open
edenbuilds wants to merge 4 commits into
Open
edenbuilds wants to merge 4 commits into
edenbuilds wants to merge 4 commits into
Conversation
Clear the pending loop timeout and set finished when the socket closes or errors, so Redis/BullMQ status polling does not continue after the client hangs up (firecrawl#4242). Applied to v1 and v2 controllers.
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Fix all with cubic | Re-trigger cubic
Register close/error handlers before any await (including auth), bail if the socket is already closed, and re-check finished after each Redis / BullMQ poll so a hangup cannot leave the 1s loop running.
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Route every early return that detects a non-OPEN socket through stop() so a CLOSING→CLOSED race cannot leave a pending setTimeout alive before the async close handler runs.
Upstream removed Sentry entirely in favor of OpenTelemetry (firecrawl#4555), which is why this hunk conflicted even though upstream never touched this function: the base state on both sides had no Sentry usage. Resolving in favor of this branch's closedDuringAuth/isSocketOpen guard would have kept an unimported `Sentry.captureException(err)` call — a leftover from before this repo dropped the Sentry dependency, and something that would throw ReferenceError on the exact disconnect-during-auth path this PR hardens. Dropped it; the existing logger.error() call below already reports the full error. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This branch has not been deployed
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
close/error, clear the pending timeout, and setfinishedso polling cannot continue after hangup.stop()helper so timeouts are cleared consistently.Fixes #4242
Test plan
setTimeout(loop, 1000)(no further Redis/queue polls for that socket).donestill closes cleanly.close.Made with Cursor
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Stops crawl-status WebSocket polling when the client disconnects, including during auth or mid-await, to prevent orphaned Redis/BullMQ polls and free resources. Applies to both v1 and v2 controllers. Fixes #4242.
Written for commit f8ab93a. Summary will update on new commits.