Perform worker update in parallel #2310
Labels
bug
Something isn't working
needs:triage
Issues that have not been investigated yet.
performance
scope:browser
Related to MSW running in a browser
Prerequisites
Environment check
msw
versionBrowsers
No response
Reproduction repository
Any example
Reproduction steps
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.
The text was updated successfully, but these errors were encountered: