Unhandled request for webpack files during Next.js fast refresh #978
-
Hi, thanks for your hard work on the library! Appreciate it if you could take a look at the following issue. Environment
Reproduction
Request handlersSee: reproduction Actual requestSee: reproduction Current behaviorWarns about unhandled request for webpack files during Next.js fast refresh Expected behaviorNo warning Screenshots |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey, @ryandi-tiket. Thanks for raising this. MSW intercepts all outgoing requests on the page, including those from webpack's Fast Refresh. It's hard for us to assume which requests are internal (such as webpack's request) and which are intended by you. We delegate that decision to you instead. You see the warnings because MSW warns you on unhandled requests by default. I understand that seeing such warnings from internal tooling pollutes the console, so you have a few options to opt out of this behavior. (Recommended) Option 1: Whitelist internal requestsworker.start({
onUnhandledRequest(request) {
// Whenever there's an unhandled request which path
// starts from "/_next", ignore it.
if (request.url.pathname.startsWith('/_next')) {
return
}
console.warn('Unhandled: %s %s', request.method, request.url.href)
}
}) The nature of these internal events is defined by the tooling you're using (i.e. NextJS). That's why whitelisting them should live as close to the tooling as possible, being your application. This way you can adjust the whitelists according to the breaking changes in your tooling if any. Since you rarely switch from NextJS to something else entirely, you only have to do this once. Option 2: Change the
|
Beta Was this translation helpful? Give feedback.
Hey, @ryandi-tiket. Thanks for raising this.
MSW intercepts all outgoing requests on the page, including those from webpack's Fast Refresh. It's hard for us to assume which requests are internal (such as webpack's request) and which are intended by you. We delegate that decision to you instead.
You see the warnings because MSW warns you on unhandled requests by default. I understand that seeing such warnings from internal tooling pollutes the console, so you have a few options to opt out of this behavior.
(Recommended) Option 1: Whitelist internal requests