Skip to content
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

Move request error message from the worker to the main thread #1683

Closed
1 task done
Tracked by #1436
kettanaito opened this issue Aug 2, 2023 · 2 comments · Fixed by #1734
Closed
1 task done
Tracked by #1436

Move request error message from the worker to the main thread #1683

kettanaito opened this issue Aug 2, 2023 · 2 comments · Fixed by #1734
Assignees
Labels
BREAKING CHANGE Pull request introducing breaking changes. DX feature scope:browser Related to MSW running in a browser
Milestone

Comments

@kettanaito
Copy link
Member

Scope

Improves an existing behavior

Compatibility

  • This is a breaking change

Feature description

Right now, whenever any request errors, MSW will produce the error message saying that something went wrong and it's unlikely an issue with MSW. That error message is really meant only for one purpose: to facilitate exceptions rising from the request handlers. But since it's just a try/catch block around the entire fetch event in the worker, that message also gets printed when extraneous request error, including requests that are meant to error by the developer.

Expected behavior

  • The current message is printed only upon an exception originating from the request handlers the user has defined.
  • The current message is not printed upon any other request error, if those requests or their handling has nothing to do with MSW.

References

// At this point, any exception indicates an issue with the original request/response.
console.error(
`\
[MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`,
request.method,
request.url,
`${error.name}: ${error.message}`,
)
}),

@kettanaito kettanaito added feature scope:browser Related to MSW running in a browser DX labels Aug 2, 2023
@kettanaito
Copy link
Member Author

@thepassle, thanks for suggesting this. I opened the issue to keep track of it. If you have any feedback to share on this or how it should behave, please let me know. Thanks.

@kettanaito kettanaito added this to the 2.0.0 milestone Aug 2, 2023
@thepassle
Copy link
Contributor

including requests that are meant to error by the developer.

Additionally: requests that are not related to MSW at all

But otherwise this looks good to me :) Thanks for creating the issue, I hadn't got round to it yet!

@kettanaito kettanaito self-assigned this Aug 18, 2023
@kettanaito kettanaito added the BREAKING CHANGE Pull request introducing breaking changes. label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE Pull request introducing breaking changes. DX feature scope:browser Related to MSW running in a browser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants