-
-
Notifications
You must be signed in to change notification settings - Fork 562
fix(setupWorker): handle in-flight requests after calling worker.stop()
#2578
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
Conversation
On unregistering the workerWhile I understand that All the ConclusionEven when the mocks are stopped, the worker MUST still be responsible for network control, but each outgoing request will always receive the |
commit: |
66daf1c to
d6205ab
Compare
Released: v2.11.2 🎉This has been released in v2.11.2! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
|
This release broke our tests, some kind of timing issue. Full test suite fails but if i run just the test file that uses msw it passes. |
|
FWIW we're using |
|
@hugomrdias, are you using fake timers in your tests, too? If not, can you think of something related to these changes that your test might be doing? Thanks for letting me know. You can pin the previous version while I resolve this issue. Can someone please open an issue for this, please? |
|
There's also a solid chance that I will conclude that this isn't an issue. Spend this time investigating how you can improve your test suite by ideally dropping fake timers. You need them extremely rarely in browser tests. Thanks. |
we are using https://percy.io/ for visual regression testing and quite a few of our snapshoted pages contain relative times like "3 days ago" but also absolute times. without fake timers these snapshots couldn't be stable.
the way I've seen this resolved in other places in the past was by saving a reference to
done: #2581 |
|
No, I'm not using fake timers |
This is nice but if you happen to mock timers before importing I would love to discuss this more in the issue you opened. Thanks! |
|
My current guess is that .stop from one file triggers after the .start from another file |
|
I am having a similar issue with the one described by @hugomrdias. I am not using fake timers. I have a Vitest test suite. One file with 2 tests has started failing after we upgraded to 2.11.2. If I run each test independently, everything works. When I run both tests, then one of the is failing. Seems the last test is always failing (I changed their order in the file and always the last one fails). It also seems that I just receive the mocked response in the first test. Once I call |
rettime#2558Changes
rettimeforWorkerChanneland dropcontext.eventsaltogether.worker.stop().MOCK_DEACTIVATEevent altogether. When the client callsworker.stop(), that doesn't affect the worker in any way. The state of mocking being disabled is entirely client-side state and so it's kept on the client (context.isMockingEnabled). The worker still handles the requests even for disabled clients, but such requests always get thePASSTHROUGHhandling instruction.RESPONSEworker event listener on the client after callingworker.stop(). TheREQUESTevent listener MUST remain since the worker now handles requests for turned-off clients as well.fetchlistener now creates a timestamp of when it's intercepted a request. The client sets its own timestamp whenworker.stop()has been called. TheREQUESTlistener compares the two timestamps to see if requests happened before the worker has been stopped.Roadmap
WorkerChannelrefactor.