Repository navigation
[vite-plugin] Preserve WebSockets owned by other v1 listeners - #16504
Conversation
🦋 Changeset detectedLatest commit: 15f30ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
@dedsec-terminal (recorded author of #15659) and @petebacondarwin (verified human ant-core approver), could you please check this Vite plugin v1 backport and approve it if it looks good? V1 has the same shared upgrade-listener ownership bug. The original fix and both real-socket regressions apply directly. Main's equivalent cookie-forwarding refactor #16488 is unnecessary: v1 keeps its existing response-cookie handling, while earlier #16501 supplies the useful incoming-header fix. Build, checks/types, all 219 plugin tests, retained fixtures and 4 WebSocket tests in each of dev and preview pass. |
|
Codeowners approval required for this PR:
|
|
💬 Approved with comments — The ownership check is correct for the DevTools case and unclaimed upgrades still close. One WARNING about test coverage for two new branches (no production impact) and one SUGGESTION about an unclosed Worker WebSocket in an edge case. Findings: 1 warning · 1 suggestion The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔧 Fix with your agentPaste the following into your coding agent to investigate and fix these issues. 📋 Code Quality:
|
commit: |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
|
The pipelining issue in the review is real — I reproduced it with a pipelined - const bytesWrittenAtStart = (socket as unknown as Socket).bytesWritten ?? 0;
- const isClaimed = () => socket.destroyed || ((socket as unknown as Socket).bytesWritten ?? 0) > bytesWrittenAtStart;
+ const isClaimed = () => socket.destroyed || socket.listenerCount("data") > 0;I opened #16516 with the change and a regression test, but it was auto-closed by the collaborator policy. The test is still visible there if useful. Happy to re-review once the backport has the updated check. |
Backports #15659 to Vite plugin v1.
V1's upgrade handler also destroys the socket when its Worker does not route a WebSocket, even if another listener already completed the handshake. Capture the socket write count before other listeners run and leave a claimed socket alone, including asynchronous error paths. Unclaimed upgrades still close normally.
Retain the original real-socket regressions for an owning DevTools-style listener and an unclaimed route. V1 keeps its existing, equivalent response-cookie forwarding implementation; main's behavior-equivalent cleanup #16488 is not a prerequisite and is not copied just to maintain mapping.
Stacked on #16503 (export-cache cleanup). This PR contains only the useful remaining WebSocket ownership fix, its plugin tests, and original patch changeset.
Validation: Node 22.22.1 / pnpm 10.33.0;
pnpm build,pnpm check(including types),pnpm test:ci,pnpm test:fixtures, and 4 WebSocket playground tests in each of dev and preview pass.Note
This is a contribution from an AI agent: Codex.