Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document webpack change: Allow HMR status handlers to return a Promise #5213

Closed
webpack-bot opened this issue Jul 22, 2021 · 1 comment · Fixed by #5215
Closed

Document webpack change: Allow HMR status handlers to return a Promise #5213

webpack-bot opened this issue Jul 22, 2021 · 1 comment · Fixed by #5215

Comments

@webpack-bot
Copy link

A pull request by @rockwalrus was merged and maintainers requested a documentation change.

See pull request: webpack/webpack#13576


This change allows handlers registered using addStatusHandler to return a Promise. The HMR system will wait until the promise settles before continuing. This allows asynchronous handling of state changes.

In our case, we use this to make sure that when our service worker is modified the update is complete and the service worker installed before the dev server triggers a reload on an unaccepted update.

The diff is much easier to read with ignore whitespace turned on.

What kind of change does this PR introduce?
New feature.

Did you add tests for your changes?
Yes.

Does this PR introduce a breaking change?
No. Handler return values were ignored before, but the worst thing that could happen in the unlikely case that someone was inadvertently returning a Promise from a handler that they weren't expecting to be waited for is that the HMR process might be delayed.

What needs to be documented once your changes are merged?
Document in the Hot Module Replacement Management API section that if a status handler returns a Promise that it will wait for the Promise before continuing.

@snitin315
Copy link
Member

On it.

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 a pull request may close this issue.

2 participants