Skip to content

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

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

jasleenkaur-qed42 wants to merge 1 commit into
vitejs:v7from
jasleenkaur-qed42:fix/backport-v7-22992

Conversation

@jasleenkaur-qed42

Copy link
Copy Markdown

Summary

Backport of #22992 to v7.

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-v7 ready!

Name Link
🔨 Latest commit 067f3bd
🔍 Latest deploy log https://app.netlify.com/projects/vite-docs-v7/deploys/6aead389bcf545cda17bbf61
😎 Deploy Preview https://deploy-preview-23987--vite-docs-v7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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