Repository navigation
Create WebSocket revocation promises lazily - #8178
Conversation
There was a problem hiding this comment.
Superseded by the review of
20264adf.
This review, of b9334b8f
💬 Approved with comments — The lazy revocation logic is correct and well tested. The only issue is an optional formatting fix: one test line is longer than 100 columns.
Findings: 1 suggestion (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 suggestion
The lazy revocation logic is correct. One test line is longer than 100 columns.
Recommendation: 💬 Optional Nits
- [SUGGESTION] worker-interface-test.c++:109 is 106 columns, over the 100-column limit enforced by clang-format. (
src/workerd/io/worker-interface-test.c++:109)
View full review
RevokePromiseSource builds the forked promise on the first addBranch() call and switches state only after the factory returns. The reference to it held by RevocableWebSocketHttpResponse points into the interface object, and the response is attached to the request promise, so this adds no new lifetime assumption beyond the existing WorkerInterface&. The eager overload still delivers the same rejection to every branch.
One formatting nit: worker-interface-test.c++:109 is 106 columns.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
⚡ Performance: ✅ LGTM
No performance issues. The change cuts per-request cost for ordinary HTTP requests.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: b9334b8f
There was a problem hiding this comment.
Superseded by the review of
57a88500.
This review, of 20264adf
✅ Approved — The formatting issue from the last review is fixed and no new issues were found. The lazy revocation promise is created at most once and shared correctly, and tests cover it.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security issues found.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
- The over-long line in
worker-interface-test.c++is fixed. The lambda inmakeRevokeProm()is now wrapped, and every changed C++ file stays within 100 columns. RevokePromiseSource::addBranch()is correct:- It calls the factory at most once.
- If the factory throws, the state stays as it was, so the next call tries again.
- The stored function is only destroyed after the factory has returned.
RevocableWebSocketHttpResponseholds a reference into the interface object. The response is attached to the request promise, so this adds no lifetime assumption beyond the existingWorkerInterface&.- The new tests cover each behaviour the description lists: the factory is never called for ordinary responses, it is called once and shared across WebSockets, a WebSocket accepted after revocation is still revoked, a CONNECT tunnel is neutered, and the eager overload still revokes.
⚡ Performance: ✅ LGTM
No performance issues. Ordinary HTTP requests no longer pay to fork the revocation promise.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 20264adf
newRevocableWebSocketWorkerInterface() forks the revocation promise when the wrapper is built, and again for every request, though the promise only matters once an event opens a WebSocket or a CONNECT tunnel. Callers whose revocation promise is costly to set up, such as one that waits on a cross-thread wait list, pay for it on every ordinary HTTP request. Add an overload that takes a factory for the revocation promise. The wrapper calls it at most once, when an event first opens a WebSocket or CONNECT tunnel, and shares the one forked promise among everything it opens. The promise overload keeps its behavior. bench-revocable-worker-interface sends an ordinary request through the wrapper, revoking through a CrossThreadWaitList. Optimized build, 10 repetitions: eager promise 462 ns/request (cv 2.6%) factory 144 ns/request (cv 3.3%) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20264ad to
57a8850
Compare
There was a problem hiding this comment.
✅ Approved — The formatting issue from the last review is fixed and no new issues were found. The lazy revocation promise is created at most once and shared correctly, and tests cover it.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security issues found.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
- The over-long line in
worker-interface-test.c++is fixed. The lambda inmakeRevokeProm()is now wrapped, and every changed C++ file stays within 100 columns. RevokePromiseSource::addBranch()is correct:- It calls the factory at most once.
- If the factory throws, the state stays as it was, so the next call tries again.
- The stored function is only destroyed after the factory has returned.
RevocableWebSocketHttpResponseholds a reference into the interface object. The response is attached to the request promise, so this adds no lifetime assumption beyond the existingWorkerInterface&.- The new tests cover each behaviour the description lists: the factory is never called for ordinary responses, it is called once and shared across WebSockets, a WebSocket accepted after revocation is still revoked, a CONNECT tunnel is neutered, and the eager overload still revokes.
⚡ Performance: ✅ LGTM
No performance issues. Ordinary HTTP requests no longer pay to fork the revocation promise.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 57a88500 — same changes as 20264adf, so this is that commit's review (no new review was run; line numbers are as of 20264adf)
newRevocableWebSocketWorkerInterface()forks the revocation promise when the wrapper is built, and again for every request, though the promise only matters once an event opens a WebSocket or a CONNECT tunnel. Callers whose revocation promise is costly to set up, such as one that waits on a cross-thread wait list, pay for it on every ordinary HTTP request.This adds an overload that takes a factory for the revocation promise. The wrapper calls it at most once, when an event first opens a WebSocket or CONNECT tunnel, and shares the one forked promise among everything it opens. The existing promise overload keeps its behavior.
Tests
worker-interface-test: the factory is never called for ordinary responses; it is called once and shared across WebSockets; a WebSocket accepted after revocation was triggered is still revoked; a CONNECT tunnel is neutered; the eager overload still revokes. Passes with--runs_per_test=5.Benchmark
bench-revocable-worker-interfacesends an ordinary request through the wrapper, revoking through aCrossThreadWaitList(optimized build, 10 repetitions):🤖 Generated with Claude Code