Skip to content

Commit 1123f1a

Browse files
committed
fix(node-http-handler): stop waiting for continue event on error
1 parent 4164757 commit 1123f1a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/node-http-handler/src/write-request-body.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function writeRequestBody(
2121
const expect = headers["Expect"] || headers["expect"];
2222

2323
let timeoutId = -1;
24+
let hasError = false;
2425

2526
if (expect === "100-continue") {
2627
await Promise.race<void>([
@@ -32,11 +33,22 @@ export async function writeRequestBody(
3233
clearTimeout(timeoutId);
3334
resolve();
3435
});
36+
httpRequest.on("error", () => {
37+
hasError = true;
38+
clearTimeout(timeoutId);
39+
// this handler does not reject with the error
40+
// because there is already an error listener
41+
// on the request in node-http-handler
42+
// and node-http2-handler.
43+
resolve();
44+
});
3545
}),
3646
]);
3747
}
3848

39-
writeBody(httpRequest, request.body);
49+
if (!hasError) {
50+
writeBody(httpRequest, request.body);
51+
}
4052
}
4153

4254
function writeBody(

0 commit comments

Comments
 (0)