Repository navigation
Conversation
🦋 Changeset detectedLatest commit: b230b35 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @hyfdev. Thanks for taking the time to contribute to Workers SDK. This PR has been automatically closed because you are not currently a registered (vouched) collaborator for this repository. AI tools now let our team generate proposed code changes quickly. Reviewing changes, checking that they solve the right problem, and maintaining code quality over time still take substantial care and effort. We therefore limit PRs to registered collaborators so we can focus that effort where it is most useful. For the majority of external contributors, the most effective way to help is through issues: describing a problem or use case, providing a minimal reproduction, investigating its cause, or helping us verify a fix. Those contributions help us understand what needs to change and are very welcome. We will take an initial look at this PR and decide whether it is something we want to invest time in reviewing and maintaining. We may reopen it if we decide to proceed, but we cannot guarantee that it will be reopened or receive a full review. |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/test-server
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
64f4ec2 to
837f33b
Compare
837f33b to
1a8bc4c
Compare
1a8bc4c to
b230b35
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
This pull request's reviews are posted as pull request reviews: see the review of |
|
clanky review |
There was a problem hiding this comment.
💬 Approved with comments — The fix is sound and well tested. One WARNING remains: a compressed rejection body reaches the client without its Content-Encoding header. That only happens when the Worker compresses the body, and the author has already said Miniflare needs a follow-up for it.
Findings: 1 warning (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.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #17213.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] A compressed rejection body is forwarded without its Content-Encoding header, so the client cannot decode it. dispatchFetch deletes the header (packages/miniflare/src/index.ts:3303), but the WebSocket path never decodes the body.
- **File:** packages/vite-plugin-cloudflare/src/websockets.ts:104
📋 Code Quality: ⚠️ 1 warning
One edge case: a compressed rejection body is forwarded without its Content-Encoding header.
Recommendation: 📝 Minor Comments
- [WARNING] A compressed rejection body is forwarded without its Content-Encoding header, so the client cannot decode it. dispatchFetch deletes the header (packages/miniflare/src/index.ts:3303), but the WebSocket path never decodes the body. (
packages/vite-plugin-cloudflare/src/websockets.ts:104)
View full review
The forwarding path is clear. Using redirect: "manual" and checking socket.destroyed before the webSocket check are both correct. Closing the runtime socket in Miniflare's unexpected-response handler on end fixes the reset after the body is read.
One gap remains. dispatchFetch deletes Content-Encoding from every response (packages/miniflare/src/index.ts:3303). That is correct for HTTP responses, which undici decodes. The WebSocket unexpected-response path, though, passes the body bytes through without decoding them. So when a Worker compresses its rejection body, sendResponse writes compressed bytes under headers that no longer say they are compressed. The author says in the discussion that this needs a Miniflare fix. It is not a regression, since on main the client got no response at all.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security issues found.
📖 AGENTS.md: ✅ LGTM
The change follows the repository's conventions.
⚡ Performance: ✅ LGTM
No performance issues found.
📝 Documentation: ✅ LGTM
The changesets describe the behaviour change accurately.
Reviewed commit: b230b359
Fixes #15170.
In
vite devandvite preview, when the Worker answers a WebSocket upgrade with a non-101 response, such as a401from an auth check, the plugin destroys the socket and the client gets no response at all.The plugin now sends the Worker's status, headers, and body, as
wrangler devdoes, and then closes the connection.A redirect is sent as is instead of being followed, so the client gets the Worker's
302andLocation.Reading that response's body used to leave Miniflare's connection to the runtime open with no
errorlistener.On Windows, disposing Miniflare, for example on a dev server restart, then threw
ECONNRESET.Miniflare now closes that connection once the body has been read.
Before, a
wsclient sees:After: