From c079b9366ff2231a806c9746f0dfb4a0ec34e5d1 Mon Sep 17 00:00:00 2001 From: John Lin Date: Sat, 23 Nov 2024 07:43:37 -0800 Subject: [PATCH] Fix a crash with Got accessing a non-existent request (#2391) --- source/core/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/index.ts b/source/core/index.ts index 12c98d213..d5a7aa754 100644 --- a/source/core/index.ts +++ b/source/core/index.ts @@ -490,7 +490,7 @@ export default class Request extends Duplex implements RequestEvents { this._request.end((error?: Error | null) => { // eslint-disable-line @typescript-eslint/ban-types // The request has been destroyed before `_final` finished. // See https://github.com/nodejs/node/issues/39356 - if ((this._request as any)._writableState?.errored) { + if ((this._request as any)?._writableState?.errored) { return; }