You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Send back the response clone for the "response:*" life-cycle events.
@@ -220,13 +221,11 @@ async function getResponse(event, client, requestId) {
220
221
221
222
console.error(
222
223
`\
223
-
[MSW] Request handler function for "%s %s" has thrown the following exception:
224
+
[MSW] Uncaught exception in the request handler for "%s %s":
224
225
225
-
${parsedBody.errorType}: ${parsedBody.message}
226
-
(see more detailed error stack trace in the mocked response body)
226
+
${parsedBody.location}
227
227
228
-
This exception has been gracefully handled as a 500 response, however, it's strongly recommended to resolve this error.
229
-
If you wish to mock an error response, please refer to this guide: https://mswjs.io/docs/recipes/mocking-error-responses\
228
+
This exception has been gracefully handled as a 500 response, however, it's strongly recommended to resolve this error, as it indicates a mistake in your code. If you wish to mock an error response, please see this guide: https://mswjs.io/docs/recipes/mocking-error-responses\
230
229
`,
231
230
request.method,
232
231
request.url,
@@ -241,6 +240,12 @@ If you wish to mock an error response, please refer to this guide: https://mswjs
241
240
242
241
self.addEventListener('fetch',function(event){
243
242
const{ request }=event
243
+
constaccept=request.headers.get('accept')||''
244
+
245
+
// Bypass server-sent events.
246
+
if(accept.includes('text/event-stream')){
247
+
return
248
+
}
244
249
245
250
// Bypass navigation requests.
246
251
if(request.mode==='navigate'){
@@ -264,11 +269,22 @@ self.addEventListener('fetch', function (event) {
264
269
265
270
returnevent.respondWith(
266
271
handleRequest(event,requestId).catch((error)=>{
272
+
if(error.name==='NetworkError'){
273
+
console.warn(
274
+
'[MSW] Successfully emulated a network error for the "%s %s" request.',
275
+
request.method,
276
+
request.url,
277
+
)
278
+
return
279
+
}
280
+
281
+
// At this point, any exception indicates an issue with the original request/response.
267
282
console.error(
268
-
'[MSW] Failed to mock a "%s" request to "%s": %s',
283
+
`\
284
+
[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.`,
0 commit comments