Repository navigation
[vite-plugin] Route DevTools WebSocket upgrades explicitly - #16519
Conversation
|
| Name | Type |
|---|---|
| @cloudflare/vite-plugin | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
|
Codeowners approval required for this PR:
Show detailed file reviewers |
|
I'm Bonk, and I've done a quick review of your PR. Routes DevTools WebSocket upgrades explicitly and removes generic socket ownership detection.
|
|
💬 Approved with comments — The explicit DevTools path check is correct, and the tests cover it well. Two INFO notes remain: the deliberate narrowing to the DevTools path, and the hard-coded path. Findings: 2 info 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: 💬 2 infoThe DevTools path is now routed correctly. Two INFO notes: the narrower scope compared with the removed socket-ownership heuristic, and the hard-coded path. Recommendation: 💬 Optional Nits
View full review
The tests cover DevTools message exchange, query strings, exact-path matching, Sandbox forwarding and the pipelined-HTTP ✅ All other checks passed🔒 Security: ✅ LGTMNo security issues found. Sandbox preview hosts still forward every upgrade, and parsing the URL with 📖 AGENTS.md: ✅ LGTMNo AGENTS.md guidance needs updating. ⚡ Performance: ✅ LGTMNo performance issues. The change removes per-socket byte-count tracking and the extra listeners, which simplifies the upgrade path. 📝 Documentation: ✅ LGTMThe changeset is accurate for this change. Reviewed commit: |
@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/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Fixes #15654. Supersedes #16516.
Leave WebSocket upgrades at
/__devtools/__wsto Vite DevTools before dispatching to the Worker. MatchingURL.pathnamealso handles query parameters while keeping nearby paths available to the Worker. Sandbox preview hosts continue forwarding every upgrade, including this path.Remove the socket ownership heuristic introduced in #15659: the byte-count baseline, prepended listener, competing-owner checks, and deferred teardown. Worker upgrades retain disconnected-socket protection and error cleanup. The exact DevTools WebSocket path is reserved on non-Sandbox hosts even when DevTools is disabled; this deliberately scopes the fix to DevTools rather than attempting to coordinate arbitrary third-party upgrade listeners.
The shared handler covers Vite development and preview servers. Miniflare, Wrangler, and the Vitest plugin need no changes because this concerns routing on Vite's shared Node HTTP server.
Validation:
pnpm -w test:ci -F @cloudflare/vite-plugin -- src/__tests__/websockets.spec.ts— 19 tests passed, including DevTools message exchange, query parameters, exact path matching, Sandbox forwarding, and a deterministic pipelined HTTP regression.pnpm --filter @cloudflare/vite-plugin check:type— passed.pnpm check:lintandpnpm check:formatfor the changed files — passed.