Patch got@11.8.2 to fix onCancel error
This commit is contained in:
parent
9d04daff5f
commit
aabbd0c041
1 changed files with 44 additions and 0 deletions
44
patches/got+11.8.2.patch
Normal file
44
patches/got+11.8.2.patch
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
diff --git a/node_modules/got/dist/source/as-promise/index.js b/node_modules/got/dist/source/as-promise/index.js
|
||||||
|
index 9575c09..a00a014 100644
|
||||||
|
--- a/node_modules/got/dist/source/as-promise/index.js
|
||||||
|
+++ b/node_modules/got/dist/source/as-promise/index.js
|
||||||
|
@@ -33,6 +33,7 @@ function asPromise(normalizedOptions) {
|
||||||
|
const promise = new PCancelable((resolve, reject, onCancel) => {
|
||||||
|
const makeRequest = (retryCount) => {
|
||||||
|
const request = new core_1.default(undefined, normalizedOptions);
|
||||||
|
+ let isResolved = false;
|
||||||
|
request.retryCount = retryCount;
|
||||||
|
request._noPipe = true;
|
||||||
|
onCancel(() => request.destroy());
|
||||||
|
@@ -118,6 +119,7 @@ function asPromise(normalizedOptions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalResponse = response;
|
||||||
|
+ isResolved = true;
|
||||||
|
resolve(request.options.resolveBodyOnly ? response.body : response);
|
||||||
|
});
|
||||||
|
const onError = (error) => {
|
||||||
|
@@ -127,9 +129,11 @@ function asPromise(normalizedOptions) {
|
||||||
|
const { options } = request;
|
||||||
|
if (error instanceof types_1.HTTPError && !options.throwHttpErrors) {
|
||||||
|
const { response } = error;
|
||||||
|
+ isResolved = true;
|
||||||
|
resolve(request.options.resolveBodyOnly ? response.body : response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+ isResolved = true;
|
||||||
|
reject(error);
|
||||||
|
};
|
||||||
|
request.once('error', onError);
|
||||||
|
@@ -140,7 +144,10 @@ function asPromise(normalizedOptions) {
|
||||||
|
onError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- makeRequest(newRetryCount);
|
||||||
|
+
|
||||||
|
+ if (!isResolved) {
|
||||||
|
+ makeRequest(newRetryCount);
|
||||||
|
+ }
|
||||||
|
});
|
||||||
|
proxy_events_1.default(request, emitter, proxiedRequestEvents);
|
||||||
|
};
|
Loading…
Reference in a new issue