Skip to content

STOR-5552: Serialize WebSocket writes across hibernation - #7147

Open
apeacock1991 wants to merge 2 commits into
mainfrom
apeacock/stor-5552-pump-settlement-barrier
Open

STOR-5552: Serialize WebSocket writes across hibernation#7147
apeacock1991 wants to merge 2 commits into
mainfrom
apeacock/stor-5552-pump-settlement-barrier

Conversation

@apeacock1991

@apeacock1991 apeacock1991 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

A hibernatable WebSocket can replace its API adapter while the old adapter's output pump is still blocked in kj::WebSocket::send().Writes from the revived adapter then race the old send and hit the
single-send assertion.

Carry a settlement-only signal from the old pump through the hibernation package. The hibernation manager uses it to order revived sends, closes, and auto-responses without retaining the old pump or its IoContext.

The barrier does not preserve a message canceled during IoContext
destruction. It only prevents a replacement adapter from writing before
the old pump has settled.

@apeacock1991
apeacock1991 requested review from a team as code owners August 27, 2026 13:05
Comment thread src/workerd/io/legacy-hibernation-manager.c++
@ask-bonk

ask-bonk Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

PR #7147 serializes hibernatable WebSocket writes across revival.

  1. [HIGH] src/workerd/io/legacy-hibernation-manager.c++:227 changes behavior for all compatibility dates without a compatibility flag. Posted an inline suggestion.

github run

Comment thread src/workerd/api/web-socket.c++
A WebSocket pump can remain blocked after its API WebSocket
hibernates. A revived adapter can then start a second send on the same
native socket, which trips KJ's single-send assertion.

Transfer a settlement-only pump signal through the hibernation
package. Use it to order revived sends and auto-responses without
retaining the old pump or its IoContext. Cancel deferred write
continuations before destroying the native socket.

Add coverage for repeated hibernation, active auto-responses after
revival, and manager teardown with a deferred response.
@apeacock1991
apeacock1991 force-pushed the apeacock/stor-5552-pump-settlement-barrier branch from b8ec734 to ebfab60 Compare August 27, 2026 14:52
Only hibernatable WebSockets transfer pump completion across adapter
replacement. Avoid creating completion promises for every regular
WebSocket pump.

Centralize write-barrier branching and remove stale test documentation.
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.

2 participants