Open kettanaito opened 3 days ago
stderr | modules/XMLHttpRequest/compliance/xhr-middleware-exception.test.ts > handles exceptions as instructed in "unhandledException" listener (request error)
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (/Users/kettanaito/Projects/mswjs/interceptors/node_modules/.pnpm/jsdom@16.7.0/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:63:19)
at EventEmitter.<anonymous> (/Users/kettanaito/Projects/mswjs/interceptors/node_modules/.pnpm/jsdom@16.7.0/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)
at EventEmitter.emit (node:events:525:35)
at Request.<anonymous> (/Users/kettanaito/Projects/mswjs/interceptors/node_modules/.pnpm/jsdom@16.7.0/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:401:14)
at Request.emit (node:events:513:28)
at ClientRequest.<anonymous> (/Users/kettanaito/Projects/mswjs/interceptors/node_modules/.pnpm/jsdom@16.7.0/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:121:14)
at ClientRequest.emit (node:events:513:28)
at Socket.socketErrorListener (node:_http_client:502:9)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8) undefined
· sets "credentials" to "omit" on isomorphic request when "withCredentials" is not set
· sets "credentials" to "omit" on isomorphic request when "withCredentials" is false
· responds with an ArrayBuffer when "responseType" equals "arraybuffer"
Cancelling test run. Press CTRL+c again to exit forcefully.
Not sure if this is intended. The test passes but the error looks weird. Need to check if it's intentional, and fix it if it's not.
This change also lays foundation for supporting
controller.abort()
(or even better—useAbortSignal
) to abort any intercepted request. This would be awesome to ship in the future.Roadmap
utils/RequestController.ts
class. It's kind of similar but is used for a deferred response resolution. I suspect we can throw it away.request.respondWith()
.controller: RequestController
to the request event listener arguments.RequestController
respondWith
multiple calls tests from these unit testsonResponseError
andonAborted
scenarios (these were not supported previously and can be treated as a separate bugfix)