Stopping and starting MSW will cause multiple "instances"
See original GitHub issueDescribe the bug
I have a use case where only I start MSW when user selects “development” data. First time it works fine, but if the user logs out and in again, i.e. stopping and starting MSW, then now it’ll return twice requests twice. It will also write “Mocking enabled” twice. Basically every time I stop and start MSW it adds an extra instance.
Environment
msw: 0.19.3
nodejs: 13.11.0
yarn: 1.22.4
Microsoft Edge: Version 83.0.478.50
To Reproduce
- Start a worker.
- Call .stop() on that worker.
- Start a new worker.
Expected behavior
Expected mocking to only be enabled once
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Eye on Ethics - Social Work Today Magazine
In short, social workers must avoid abandoning clients. Abandonment is a legal concept that refers to instances when a professional is not available...
Read more >use() - Api - Mock Service Worker Docs
use(). Prepends given request handlers to the current server instance. Request handler added after the initial setupServer call is referred to ...
Read more >Social Worker Burnout: 8 Self-Care Tips
Caring for others can lead to social worker burnout. Here are 8 tips for social workers to take better care of themselves in...
Read more >Chapter 5: Social Work Practice Settings - Pressbooks
Indirect practice is generally when the social worker is involved in activities that consist with facilitating change through programs and policies. This type ......
Read more >6 Important Theories in Social Work & 6 Practice Models
That ensures competence in social work, which can increase social worker ... Social work theory provides a starting point for social workers to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes I can give you an hand 😄
I have tried
nextjs
example but I don’t see the problem there, I have only one log for[MSW] Mocking enabled
. Hot reload should be good if we work locally but how we can handle manual stop and start of the worker?We should add two logic maybe:
hot-reload
should remove all listenersstop()
should remove listeners too