Closed kettanaito closed 1 month ago
Also a good point that we still won't properly support this scenario:
- a. parent with MSW
- a.1. child with MSW
- a.1.1. child without MSW (request here!)
Since a.1.1 doesn't call worker.start()
, it won't be in the activeClientIds
in the worker script at all. That will trigger the regular client lookup in all visible frames, and that will still resolve with the top-level client (a).
I'd say the expectation here is that the worker
in a.1 should handle the requests coming from a.1.1.
Unfortunately, there's no hierarchical relationship of the service worker clients. You also cannot know the actual client ID on the client to do any sort of logic on the library's side. See https://github.com/w3c/ServiceWorker/issues/1556.
This has been released in v2.5.0!
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.
The problem
If the page calls
worker.start()
and has a child frame that also callsworker.start()
, the requests from the frame will only be resolved against the top-level parent'sworker
and its handlers.The solution
During the
resolveMainFrame
client lookup, if the eventclientId
is in the active client ids of the worker, return it. Don't lookup the clients because the top-level client will always match first, ignoring any underlying otherwise matching nested client ids.