Perform worker update in parallel
kettanaito opened this issue · 1 comments
Prerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- I'm using the latest
msw
version - I'm using Node.js version 18 or higher
Browsers
No response
Reproduction repository
Any example
Reproduction steps
- Have a context that activates MSW.
- Have another MSW activation in the same context.
Current behavior
When MSW finds a matching registration and attempts to reuse it, it first updates the worker. That is done to make sure that the existing worker registration is up-to-date. For example, if you are registering a worker that doesn't match the existing worker (i.e. the script has changed due to the MSW version change), the existing worker will be marked as redundant.
msw/src/browser/setupWorker/start/utils/getWorkerInstance.ts
Lines 39 to 40 in 452686d
The problem is that .update()
takes time. It needs to fetch the worker script, evaluate it byte-by-byte, comparing the old and the new scripts. That's a potential overhead that MSW doesn't have to await.
Expected behavior
Update is scheduled to run in the background. MSW resolves with the existing worker registration immediately.
Released: v2.4.10 🎉
This has been released in v2.4.10!
Make sure to always update to the latest version (npm i msw@latest
) to get the newest features and bug fixes.
Predictable release automation by @ossjs/release.