Skip to content

[vite-plugin] Route v1 DevTools WebSocket upgrades explicitly - #16540

Merged
petebacondarwin merged 1 commit into
vite-plugin-v1from
codex/vite-v1-devtools-before-runtime
Oct 28, 2026
Merged

petebacondarwin merged 1 commit into
vite-plugin-v1from
codex/vite-v1-devtools-before-runtime

Conversation

@petebacondarwin

Copy link
Copy Markdown
Contributor

Backports #16519 to Vite plugin v1, stacked directly on #16504, as requested. #16444 follows this fix in the v1 stack.

Replaces #16538: while reordering, pushing its rebased commit into the old base branch caused GitHub to mark that PR merged and delete its head branch. The v1 target branch was never changed. GitHub rejects changing that merged PR's base; this replacement keeps the same three-file fix and requested direct base, without adding another changeset or dependency upgrade.

Vite DevTools upgrades at /__devtools/__ws must reach its own listener without being dispatched to the Worker. Replace the inherited write-count heuristic from #16504 with explicit routing, preserving Sandbox forwarding. This also fixes a legitimate Worker upgrade being rejected when an earlier pipelined HTTP response finishes during dispatch. The original source, socket regressions, and existing changeset apply directly; no dependency upgrade or additional changelog entry is needed.

Validation: Node 22.22.1 / pnpm 10.33.0; pnpm build, pnpm check, pnpm test:ci, and the WebSockets playground in dev and built preview.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this fixes existing v1 WebSocket routing without changing its public API.

Note

This is a contribution from an AI agent: Codex, under the authorized v1 backport automation.


Devin Review

@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 599b671

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 1 package
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

@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team October 28, 2026 11:10
@workers-devprod

workers-devprod commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@petebacondarwin (original author) @dario-piotrowicz (human ant-core approver): please check this v1 backport of #16519 and approve it if it looks good. This replaces auto-merged #16538 after the requested reorder; it is now directly on #16504, with #16444 above it. GitHub marked the earlier PR merged into its temporary base branch when I pushed the reordered ancestry too early; vite-plugin-v1 was never changed. The same three-file source/socket-test/changeset diff passes build, all checks, retained tests and WebSockets dev/preview on its new base. The earlier request is #16538 (comment); this is its replacement review location.

@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/@cloudflare/vite-plugin@16540

commit: 599b671

devin-ai-integration[bot]

This comment was marked as resolved.

@clanky-the-clanker

clanky-the-clanker Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Approved — No issues found: the explicit DevTools path check replaces the fragile write-count heuristic, Sandbox forwarding still works, the tests cover the regressions, and the changeset is accurate.

The decision is advisory: this comment never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Low risk. The changeset is a patch entry for @cloudflare/vite-plugin, and its wording matches the new behaviour.


🔒 Security: ✅ LGTM

No security concerns in the routing change.


📖 AGENTS.md: ✅ LGTM

Consistent with the repository conventions.


📋 Code Quality: ✅ LGTM

No issues in websockets.ts or websockets.spec.ts. The url.pathname === "/__devtools/__ws" check ignores the query string, Sandbox-origin requests still reach the Worker, and removing the write-count check fixes the false rejection after an earlier pipelined response. The new tests cover DevTools routing, Sandbox forwarding, near-miss paths and the pipelined-response case.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

The updated changeset accurately describes the user-facing fix.


Reviewed commit: 599b671c — same changes as 3ca16f5a, so this is that commit's review (no new review was run; line numbers are as of 3ca16f5a)

Base automatically changed from codex/vite-v1-backport-15659 to vite-plugin-v1 October 28, 2026 11:33
@petebacondarwin
petebacondarwin force-pushed the codex/vite-v1-devtools-before-runtime branch from 3ca16f5 to 599b671 Compare October 28, 2026 11:34

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@petebacondarwin
petebacondarwin merged commit d3b872f into vite-plugin-v1 Oct 28, 2026
21 checks passed
@petebacondarwin
petebacondarwin deleted the codex/vite-v1-devtools-before-runtime branch October 28, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants