-
-
Notifications
You must be signed in to change notification settings - Fork 580
Open
Labels
bugSomething isn't workingSomething isn't workingneeds:triageIssues that have not been investigated yet.Issues that have not been investigated yet.scope:nodeRelated to MSW running in NodeRelated to MSW running in Node
Description
Prerequisites
- I confirm my issue is not in the opened issues
- I confirm the Frequently Asked Questions didn't contain the answer to my issue
Environment check
- I'm using the latest
mswversion - I'm using Node.js version 20 or higher
Node.js version
v22.21.0
Reproduction repository
https://github.com/markuslewin/msw-http-error
Reproduction steps
npm testCurrent behavior
When ClientRequest.destroy is called with an error, 2 error events are emitted to the error listener. This results in an uncaught exception for HTTP clients that only expect 1 error, such as the clients in the Azure SDK for JavaScript.
If I disable MSW by removing the line server.listen(), the tests pass, but when MSW is enabled, I receive an uncaught exception for the second error event:
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Uncaught Exception ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
AbortError: The operation was aborted. Rejecting from abort signal callback while making request.
❯ AbortSignal.<anonymous> node_modules/@typespec/ts-http-runtime/dist/esm/nodeHttpClient.js:199:36
❯ AbortSignal.[nodejs.internal.kHybridDispatch] node:internal/event_target:827:20
❯ AbortSignal.dispatchEvent node:internal/event_target:762:26
❯ runAbort node:internal/abort_controller:486:10
❯ abortSignal node:internal/abort_controller:457:3
❯ AbortController.abort node:internal/abort_controller:505:5
❯ Timeout._onTimeout node_modules/@typespec/ts-http-runtime/dist/esm/nodeHttpClient.js:85:33
❯ listOnTimeout node:internal/timers:588:17
❯ processTimers node:internal/timers:523:7
This error originated in "app.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "azure credential doesn't throw". It might mean one of the following:
- The error was thrown, while Vitest was running this test.
- If the error occurred after the test had been completed, this was the last documented test before it was thrown.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯Expected behavior
MSW should emit only 1 error event when ClientRequest.destroy is called with an error, mimicking the behavior of the original http.ClientRequest.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds:triageIssues that have not been investigated yet.Issues that have not been investigated yet.scope:nodeRelated to MSW running in NodeRelated to MSW running in Node