Repository navigation
fix(runtime-sdk): fix contextvars not being shared in WSGI streaming response - #288
Merged
Merged
Conversation
…treaming response
|
LGTM |
|
This pull request's reviews are posted as pull request reviews: see the review of |
dom96
approved these changes
Oct 28, 2026
hoodmane
reviewed
Oct 28, 2026
There was a problem hiding this comment.
✅ Approved — No issues found: the fix runs the app call, iteration and close in one shared request context, and new tests cover sharing within a stream, isolation between streams and reset on cancel.
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 concerns.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
No issues found.
wsgi.py: one copiedcontextvars.Contextcovers the app call,iter(result), everynext()andclose(). App-set values stay visible during streaming, and tokens reset in the context that created them.- Cleanup: the
try/finallyinclose_allcloseswsgi.inputeven if closing the iterable raises. - Tests: the workerd WSGI tests cover sharing within a stream, isolation between concurrent streams, and token reset on cancel. The Flask tests exercise
stream_with_context.
⚡ Performance: ✅ LGTM
No performance concerns. Running each chunk through context.run adds very little overhead.
📝 Documentation: ✅ LGTM
No documentation issues.
Reviewed commit: 0f1d4e8d
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.
fix #287
WSGI streaming response use stack switching. However, they should use the same contextvars, since they are in the same request context.