Skip to content

Conversation

@MIGUELez11
Copy link
Contributor

What

Fixed handling of undefined hash values received from rspack during hot module reload.

Why

When rspack sends an undefined hash through WebSocket messages, it causes a TypeError when trying to use indexOf on the undefined value. This happens in the following sequence:

  1. Run the dev-server

  2. Visit the page

  3. Rspack triggers a HMR and for some reason returns an empty hash

  4. The hash is handled and when triggering a reloadApp the currentHash is undefined

How

Added propert handling for undefined hash values in the hot update handler to prevent the TypeError.

Notes

I've used --no-verify for the commit as the file contains pre-existing style inconsistencies that are outside the scope of this fix.

Screenshots

The messages sent from Rspack via the WebSocket showing a type hash without data
The messages sent from Rspack via the WebSocket showing a type hash without data

The error thrown and catched with react-refresh of reloadApp trying to call currentHash.indexOf(/** @type {string} */ previousHash) >= 0
The error thrown and catched with react-refresh of reloadApp trying to call currentHash.indexOf(/** @type {string} */ previousHash) >= 0

@CLAassistant
Copy link

CLAassistant commented Dec 9, 2024

CLA assistant check
All committers have signed the CLA.

@LingyuCoder
Copy link
Contributor

Thanks for your contribution

@LingyuCoder LingyuCoder merged commit e583efc into web-infra-dev:main Dec 10, 2024
4 checks passed
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