Skip to content

Commit 29d4e32

Browse files
committed
Prepare a fix for hanging promise on Node.js 14.10.x
1 parent 27470b5 commit 29d4e32

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

source/core/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,9 +2492,8 @@ export default class Request extends Duplex implements RequestEvents<Request> {
24922492

24932493
try {
24942494
response.rawBody = await getBuffer(response);
2495+
response.body = response.rawBody.toString();
24952496
} catch {}
2496-
2497-
response.body = response.rawBody.toString();
24982497
}
24992498

25002499
if (this.listenerCount('retry') !== 0) {
@@ -2604,6 +2603,11 @@ export default class Request extends Duplex implements RequestEvents<Request> {
26042603
}
26052604

26062605
_writeRequest(chunk: any, encoding: BufferEncoding | undefined, callback: (error?: Error | null) => void): void {
2606+
if (this[kRequest]!.destroyed) {
2607+
// Probably the `ClientRequest` instance will throw
2608+
return;
2609+
}
2610+
26072611
this._progressCallbacks.push((): void => {
26082612
this[kUploadedSize] += Buffer.byteLength(chunk, encoding);
26092613

0 commit comments

Comments
 (0)