Closed ericyd closed 1 month ago
Hi, @ericyd. Thanks for reporting this.
This seems to be related to flushPromises
issue: https://github.com/mswjs/msw/issues/1163#issuecomment-1068294420. Can you please follow this thread and let me know if the suggestions fix your issue? Basically, you have to flush the promises twice.
Thanks @kettanaito , that solved the issue! I re-ran the tests using my steps to reproduce and was able to re-run 50x without failure. I consider that resolved. I've committed the fix to the demonstration repo: https://github.com/ericyd/msw-econnrefused/commit/92ef0c901fee82ebcd06a98ffe227b079002ef26
Prerequisites
Environment check
msw
versionNode.js version
v20.17.0
Reproduction repository
https://github.com/ericyd/msw-econnrefused/
Reproduction steps
Unfortunately the error is non-deterministic, but here is how I reproduced
npm ci
(if first time booting the codespace)npm test
Enter
in the terminal to re-run the test suite. For me, the tests will error within the first 10 executions which takes less than a minute to achieve.Current behavior
Here is the full console transcript from an error run:
In addition, I recorded a video showing the non-deterministic nature of this error
https://github.com/user-attachments/assets/ab0fa80b-0c56-438f-9875-2d6661d3f3d2
Expected behavior
There should never be a fetch error, or if there is, it should always be deterministic.
Additional notes
fetch
. It did not solve the issue, and in addition I don't think that's the problem since it doesn't always error.