Skip to content

Commit

Permalink
fix(node-http-handler): stop waiting for continue event on error
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Jun 7, 2023
1 parent 4164757 commit 1123f1a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/node-http-handler/src/write-request-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export async function writeRequestBody(
const expect = headers["Expect"] || headers["expect"];

let timeoutId = -1;
let hasError = false;

if (expect === "100-continue") {
await Promise.race<void>([
Expand All @@ -32,11 +33,22 @@ export async function writeRequestBody(
clearTimeout(timeoutId);
resolve();
});
httpRequest.on("error", () => {
hasError = true;
clearTimeout(timeoutId);
// this handler does not reject with the error
// because there is already an error listener
// on the request in node-http-handler
// and node-http2-handler.
resolve();
});
}),
]);
}

writeBody(httpRequest, request.body);
if (!hasError) {
writeBody(httpRequest, request.body);
}
}

function writeBody(
Expand Down

0 comments on commit 1123f1a

Please sign in to comment.