got
Advanced tools
Comparing version 12.5.2 to 12.5.3
@@ -112,2 +112,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
private _cancelTimeouts; | ||
private readonly _removeListeners; | ||
private _nativeResponse?; | ||
@@ -114,0 +115,0 @@ private _flushed; |
@@ -166,2 +166,8 @@ import process from 'node:process'; | ||
}); | ||
Object.defineProperty(this, "_removeListeners", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "_nativeResponse", { | ||
@@ -200,2 +206,3 @@ enumerable: true, | ||
this._cancelTimeouts = noop; | ||
this._removeListeners = noop; | ||
this._jobs = []; | ||
@@ -239,8 +246,2 @@ this._flushed = false; | ||
} | ||
if (this.options.signal?.aborted) { | ||
this.destroy(new AbortError(this)); | ||
} | ||
this.options.signal?.addEventListener('abort', () => { | ||
this.destroy(new AbortError(this)); | ||
}); | ||
// Important! If you replace `body` in a handler with another stream, make sure it's readable first. | ||
@@ -262,2 +263,16 @@ // The below is run only once. | ||
} | ||
if (this.options.signal) { | ||
const abort = () => { | ||
this.destroy(new AbortError(this)); | ||
}; | ||
if (this.options.signal.aborted) { | ||
abort(); | ||
} | ||
else { | ||
this.options.signal.addEventListener('abort', abort); | ||
this._removeListeners = () => { | ||
this.options.signal.removeEventListener('abort', abort); | ||
}; | ||
} | ||
} | ||
} | ||
@@ -459,2 +474,3 @@ async flush() { | ||
this._cancelTimeouts(); | ||
this._removeListeners(); | ||
if (this.options) { | ||
@@ -461,0 +477,0 @@ const { body } = this.options; |
{ | ||
"name": "got", | ||
"version": "12.5.2", | ||
"version": "12.5.3", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
251880
5495