Skip to content

fix(hmr): preserve environment snapshot during server restart (#22992) - #23988

Open
jasleenkaur-qed42 wants to merge 1 commit into
vitejs:v6from
jasleenkaur-qed42:fix/backport-v6-22992
Open

jasleenkaur-qed42 wants to merge 1 commit into
vitejs:v6from
jasleenkaur-qed42:fix/backport-v6-22992

Conversation

@jasleenkaur-qed42

Copy link
Copy Markdown

Summary

Backport of #22992 to v6.

Saving the config file while another file's HMR update is still in flight (its hotUpdate / handleHotUpdate hooks are being awaited) crashes the dev server with TypeError: Cannot set properties of undefined (setting 'error').

Root Cause

handleHMRUpdate keys hotMap by the environment instances present at the start of the update. A config-change restart replaces server.environments in place, so after the awaited hook the handler looks up environments that were never added to hotMap, and the catch block writes .error on undefined.

Changes

Testing

  • pnpm exec vitest run packages/vite/src/node/server/__tests__/hmr.spec.ts: fails without the change, passes with it
  • pnpm run test-unit, HMR playground e2e, typecheck, lint

Related Issue

Closes #23984

@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vite-docs-v6 canceled.

Name Link
🔨 Latest commit c61e0b2
🔍 Latest deploy log https://app.netlify.com/projects/vite-docs-v6/deploys/6aead3b0c513a5126bb86358

This branch has not been deployed

No deployments
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.

1 participant