interceptors: TypeError: this.agent.destroy is not a function
I am using Vitest to run the test, when I intercept the request.js requests, the program issues an error message
vitest: 0.25.2
request.js: 2.28.2
msw: 0.48.3
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: this.agent.destroy is not a function
❯ NodeClientRequest.terminate node_modules/msw/node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/NodeClientRequest.ts:361:16
❯ NodeClientRequest.respondWith node_modules/msw/node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/NodeClientRequest.ts:353:10
❯ node_modules/msw/node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/NodeClientRequest.ts:164:14
❯ processTicksAndRejections node:internal/process/task_queues:95:5
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (15 by maintainers)
@markfranco, thanks for letting me know. The versions are correct, MSW is not yet on the latest Interceptors because those work via the Fetch API already. I may try backporting this into the latest compatible release.
@kettanaito It’s apparently an issue with OctoKit. Taking a gander at their source code, I found this:
@kettanaito it was a premature celebration after all… the interceptor is apparently not doing anything at all in v19, which would explain it not throwing either.
edit: It’s happening both in 17.9.1 and 16.19.0
@kettanaito I am experiencing this same error, not related to
request.js
(reported it over at the msw repo in https://github.com/mswjs/msw/issues/1515) while trying to intercept OctoKit requests.I tried dropping some random console calls for debugging and from what I can see, it appears
this.agent
is undefined at that point, for some reason.