summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/node/polyfills/http2.ts18
-rw-r--r--ext/node/polyfills/internal/errors.ts4
2 files changed, 19 insertions, 3 deletions
diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts
index cd6c47eeb..b4cda65f8 100644
--- a/ext/node/polyfills/http2.ts
+++ b/ext/node/polyfills/http2.ts
@@ -840,6 +840,11 @@ async function clientHttp2Request(
reqHeaders,
);
+ if (session.closed || session.destroyed) {
+ debugHttp2(">>> session closed during request promise");
+ throw new ERR_HTTP2_STREAM_CANCEL();
+ }
+
return await op_http2_client_request(
session[kDenoClientRid],
pseudoHeaders,
@@ -900,6 +905,12 @@ export class ClientHttp2Stream extends Duplex {
session[kDenoClientRid],
this.#rid,
);
+
+ if (session.closed || session.destroyed) {
+ debugHttp2(">>> session closed during response promise");
+ throw new ERR_HTTP2_STREAM_CANCEL();
+ }
+
const [response, endStream] = await op_http2_client_get_response(
this.#rid,
);
@@ -918,7 +929,12 @@ export class ClientHttp2Stream extends Duplex {
);
this[kDenoResponse] = response;
this.emit("ready");
- })();
+ })().catch((e) => {
+ if (!(e instanceof ERR_HTTP2_STREAM_CANCEL)) {
+ debugHttp2(">>> request/response promise error", e);
+ }
+ this.destroy(e);
+ });
}
[kUpdateTimer]() {
diff --git a/ext/node/polyfills/internal/errors.ts b/ext/node/polyfills/internal/errors.ts
index 9e0905ef4..51bd7a025 100644
--- a/ext/node/polyfills/internal/errors.ts
+++ b/ext/node/polyfills/internal/errors.ts
@@ -2295,10 +2295,10 @@ export class ERR_HTTP2_INVALID_SETTING_VALUE extends NodeRangeError {
}
export class ERR_HTTP2_STREAM_CANCEL extends NodeError {
override cause?: Error;
- constructor(error: Error) {
+ constructor(error?: Error) {
super(
"ERR_HTTP2_STREAM_CANCEL",
- typeof error.message === "string"
+ error && typeof error.message === "string"
? `The pending stream has been canceled (caused by: ${error.message})`
: "The pending stream has been canceled",
);