-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: force bodies which are in the middle of being read to be abortable #847
base: main
Are you sure you want to change the base?
Conversation
2635fd2
to
9253f05
Compare
I manually applied the changes in Router directly to my local |
I created a temporary work-around using patch-package to modify the built code, as I was also finding my vitest tests failing due to an diff --git a/node_modules/fetch-mock/dist/esm/Router.js b/node_modules/fetch-mock/dist/esm/Router.js
index 599e79f..ef9ed5d 100644
--- a/node_modules/fetch-mock/dist/esm/Router.js
+++ b/node_modules/fetch-mock/dist/esm/Router.js
@@ -84,10 +84,19 @@ export default class Router {
const error = new DOMException('The operation was aborted.', 'AbortError');
const requestBody = request?.body || options?.body;
if (requestBody instanceof ReadableStream) {
- requestBody.cancel(error);
+ if (requestBody.locked) {
+ requestBody.getReader().cancel(error);
+ } else {
+ requestBody.cancel(error);
+ }
}
- if (callLog?.response?.body) {
- callLog.response.body.cancel(error);
+ const responseBody = callLog?.response?.body;
+ if (responseBody) {
+ if (responseBody instanceof ReadableStream && responseBody.locked) {
+ responseBody.getReader().cancel(error);
+ } else {
+ responseBody.cancel(error);
+ }
}
reject(error);
}; |
The fetch-mock library does not correctly handle the case of an abort controller firing after a request has completed. This is a known issue but not yet fixed upstream. see wheresrhys/fetch-mock#847
The fetch-mock library does not correctly handle the case of an abort controller firing after a request has completed. This is a known issue but not yet fixed upstream. see wheresrhys/fetch-mock#847
The fetch-mock library does not correctly handle the case of an abort controller firing after a request has completed. This is a known issue but not yet fixed upstream. see wheresrhys/fetch-mock#847
The fetch-mock library does not correctly handle the case of an abort controller firing after a request has completed. This is a known issue but not yet fixed upstream. see wheresrhys/fetch-mock#847
No description provided.