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
TypeError: Network Request Failed #971
Comments
|
Hey, @Smankusors. The current behavior is correct. MSW stands for a mocked server-side code you're writing. If there'd be such a code as That's exactly how MSW behaves:
That being said, if this behavior is confusing to developers, I see little harm in duplicating the error message directly to the console for better visibility. But I'd still leave the behavior I described above intact. |
|
If I'm not mistaken, such exception will bubble to this msw/src/utils/worker/createRequestListener.ts Lines 69 to 96 in f6fbd6c
This is also how such exceptions are translated to 500 error responses (signaling I believe if we add the suggested @Smankusors, would you be interested in working on this? I will support you during the code review if you decide so. |
|
yeah it should return 500 response, but it doesn't. The timeout returned instead. I have tried Take a look of my modified createRequestListener |
|
My jest-tests exit the process because of this, instead of just failing the test. |
Describe the bug
I received this error whenever there's code error on the handler code.
Environment
This unit testing running on Node environment
msw: 0.35.0nodejs: 16.6.0npm: 7.24.1To Reproduce
Take a look at the example of the handler code below:
Expected behavior
The error should appear like this when testing
Current behavior
But instead, TypeError appears
It seems like when the handler code failed, there's no response being sent back, resulting what it looks like timeout.
More info
I'm able to make the error shows up in the console by editing this line
msw/src/handlers/RequestHandler.ts
Line 235 in 11bb244
into this
but it's kinda ugly? What's best approach for this?
The text was updated successfully, but these errors were encountered: