Prerequisites
Environment check
Browsers
Chromium (Chrome, Brave, etc.)
Reproduction repository
https://github.com/diego-aquino/msw-worker-stop-bypass-issue
Reproduction steps
pnpm install
pnpm test
Current behavior
Starting in msw@2.11.2, I found out that workers sometimes handle requests even after worker.stop() is called.
In the reproduction repository, this expect sometimes passes, sometimes fails.
https://github.com/diego-aquino/msw-worker-stop-bypass-issue/blob/main/example.browser.test.ts#L22-L27
worker.stop();
// This expect sometimes passes, sometimes fails.
await expect(async () => {
await fetch(`${baseURL}/users`);
}).rejects.toThrowError(TypeError);
From my tests, I did not see this issue happening with server.close(), neither with worker.stop() and server.close() before 2.11.2 (I tested 2.11.1).
Expected behavior
I expected all requests made after worker.stop() was called to not be handled.
Prerequisites
Environment check
mswversionBrowsers
Chromium (Chrome, Brave, etc.)
Reproduction repository
https://github.com/diego-aquino/msw-worker-stop-bypass-issue
Reproduction steps
pnpm installpnpm testCurrent behavior
Starting in msw@2.11.2, I found out that workers sometimes handle requests even after
worker.stop()is called.In the reproduction repository, this expect sometimes passes, sometimes fails.
https://github.com/diego-aquino/msw-worker-stop-bypass-issue/blob/main/example.browser.test.ts#L22-L27
From my tests, I did not see this issue happening with
server.close(), neither withworker.stop()andserver.close()before 2.11.2 (I tested 2.11.1).Expected behavior
I expected all requests made after
worker.stop()was called to not be handled.