Websockets: Wrap the ongoingAutoResponse so it gets destructed on the…#6637
Open
Websockets: Wrap the ongoingAutoResponse so it gets destructed on the…#6637
Conversation
… IO thread. The WebSocket::AutoResponse struct holds a bare kj::Promise<void> (ongoingAutoResponse) directly on the JS heap. When V8's GC collects a WebSocketPair, the destructor chain reaches this promise under DISALLOW_KJ_IO_DESTRUCTORS_SCOPE, and if the promise holds a real async node (a ForkBranch from ws.send().fork()), destroying it triggers a fatal "KJ async object being destroyed when not allowed" error (Sentry 37914510). The fix wraps the promise in kj::Maybe<IoOwn<kj::Promise<void>>> so that destruction is deferred to the IoContext's delete queue, following the same pattern already used by outgoingMessages.
Contributor
|
UnknownError: ProviderInitError |
Contributor
|
@erikcorry Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
jasnell
approved these changes
Apr 22, 2026
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.
… IO thread.
The WebSocket::AutoResponse struct holds a bare kj::Promise (ongoingAutoResponse) directly on the JS heap. When V8's GC collects a WebSocketPair, the destructor chain reaches this promise under DISALLOW_KJ_IO_DESTRUCTORS_SCOPE, and if the promise holds a real async node (a ForkBranch from ws.send().fork()), destroying it triggers a fatal "KJ async object being destroyed when not allowed" error (Sentry 37914510). The fix wraps the promise in kj::Maybe<IoOwn<kj::Promise>> so that destruction is deferred to the IoContext's delete queue, following the same pattern already used by outgoingMessages.