Repository navigation
api: keep Hyperdrive subrequest channel alive for the CONNECT stream - #7719
bartlomieju wants to merge 4 commits into
Conversation
danlapid
left a comment
There was a problem hiding this comment.
ugh you are so right, I even fixed an internal version of this a few years ago and forgot about this
Hyperdrive::connectToDb() created a raw HTTP client over the subrequest channel and returned the connection stream, letting both the client and the channel die with the coroutine frame. When the designator resolves to a Worker service, the channel owns the WorkerEntrypoint serving the CONNECT, whose deferred drain later reads waitUntilTasks on a destroyed object and crashes the process with SIGSEGV. Attach client and channel to the returned stream so they live as long as the connection. Fixes cloudflare#6901
3ad8164 to
6416f6e
Compare
|
✅ Approved — The fix makes the Hyperdrive CONNECT stream own its HTTP client and subrequest channel, so the WorkerEntrypoint is no longer freed while it is still serving the stream. A regression test covers the crash, and no issues were found. The decision is advisory: this comment never approves, blocks or requests changes on the pull request. ✅ All checks passed📋 Code Quality: ✅ LGTMI found no issues in either changed file.
📝 Documentation: ✅ LGTMNo documentation changes are needed. The description explains the root cause and the fix clearly. Reviewed commit: |
|
The internal build won't run since this was opened from a fork. If you re-open this from a branch in cloudflare/workerd it'll run the internal build... or, if you just want to run the internal build manually to confirm nothing break i'm happy landing this with a bypass. Just let me know which you'd rather do. |
|
Superseded by #7908, opened from a branch in this repository so CI can run. |
Hyperdrive::connectToDb()created a raw HTTP client over the subrequestchannel and returned the connection stream, letting both the client and the
channel die with the coroutine frame.
When the designator resolves to a Worker service, the channel owns the
WorkerEntrypointserving theCONNECT, whose deferred drain laterreads
waitUntilTaskson a destroyed object and crashes the process withSIGSEGV.
This PR attaches client and channel to the returned stream so they live as
long as the connection.
Fixes #6901