Skip to content

[vite-plugin] Close disabled v1 HMR WebSocket upgrades - #16578

Merged
petebacondarwin merged 1 commit into
codex/vite-v1-backport-16521from
codex/vite-v1-backport-15290
Oct 30, 2026
Merged

petebacondarwin merged 1 commit into
codex/vite-v1-backport-16521from
codex/vite-v1-backport-15290

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Backports #15290 to Vite plugin v1, stacked on #16543's published runtime update.

With server.ws: false, Vite installs no HMR upgrade handler and v1 leaves the browser's raw socket pending. Pass Vite's WebSocket setting into the plugin's upgrade handler and close unclaimed HMR sockets. Preserve enabled HMR, Vite DevTools and Sandbox/Worker WebSocket routing. The source/test diff applies to v1, with the optional argument default kept enabled so preview and other callers that omit it retain their existing handoff; the existing stack contains no equivalent fix. Includes the original plugin patch changeset and tests for enabled, disabled and unspecified HMR.

Validation: Node 22.22.1/pnpm 10.33.0; pnpm check (build, types, lint, format; all 58 tasks) and the WebSocket/container-server suites pass. The first test command accidentally ran the whole plugin suite concurrently with a clean build, which removed generated Worker files mid-test; rerunning affected suites after build completion passes. Parent #16543 validates the published dependency graph and asset/WebSocket dev/preview playgrounds.


  • 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 server.ws behavior; the plugin changeset describes it.

Note

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

@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ee13faa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

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

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

workers-devprod commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@edmundhung (original author) @petebacondarwin (verified human ant-core approver): please check this v1 backport of #15290 and approve it if it looks good. The original plugin source/tests apply directly to v1, closing raw HMR upgrades when server.ws is disabled while preserving other upgrade owners. It is stacked on #16543, which already supplies the published runtime graph. Build/types/checks and the WebSocket/container-server suites pass.

devin-ai-integration[bot]

This comment was marked as resolved.

@clanky-the-clanker

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

Copy link
Copy Markdown

✅ Approved — This pull request correctly closes HMR upgrades that nothing will handle when server.ws is disabled. It includes tests and a changeset, and no issues were found.

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


✅ All checks passed

📋 Code Quality: ✅ LGTM

handleWebSocket destroys a socket only when the upgrade is a Vite HMR request, is not a Sandbox request, and viteWebSocketEnabled is false. DevTools upgrades still go to their own handler. dev.ts passes server.ws !== false, which matches how Vite treats the setting. When the argument is omitted, the default true keeps the existing handoff. The tests check the disabled, enabled and unspecified cases, and also check that dispatchFetch is never called.


📝 Documentation: ✅ LGTM

The changeset describes the user-facing fix, and the inline comment explains why the socket is destroyed.


Reviewed commit: ee13faab

@petebacondarwin
petebacondarwin force-pushed the codex/vite-v1-backport-15290 branch from 90b69f3 to ee13faa Compare October 29, 2026 14:21
@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026

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

commit: ee13faa

@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 2eae147 into vite-plugin-v1 Oct 30, 2026
25 of 27 checks passed
@petebacondarwin
petebacondarwin deleted the codex/vite-v1-backport-15290 branch October 30, 2026 10:31
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