Skip to content

Commit 87fadbb

Browse files
Nevonkuhe
authored andcommitted
fix(node-http-handler): Write request body if 100 Continue response times out
1 parent 6e70955 commit 87fadbb

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

.changeset/good-buttons-relax.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/node-http-handler": patch
3+
---
4+
5+
fix sending request when 100 Continue response takes more than 1 second

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,25 @@ describe(writeRequestBody.name, () => {
5959
await promise;
6060
}
6161
);
62+
63+
it("should send the body if the 100 Continue response is not received before the timeout", async () => {
64+
const httpRequest = Object.assign(new EventEmitter(), {
65+
end: vi.fn(),
66+
}) as any;
67+
const request = {
68+
headers: {
69+
expect: "100-continue",
70+
},
71+
body: Buffer.from("abcd"),
72+
method: "GET",
73+
hostname: "",
74+
protocol: "https:",
75+
path: "/",
76+
};
77+
78+
const promise = writeRequestBody(httpRequest, request);
79+
expect(httpRequest.end).not.toHaveBeenCalled();
80+
await promise;
81+
expect(httpRequest.end).toHaveBeenCalled();
82+
});
6283
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function writeRequestBody(
2828
if (expect === "100-continue") {
2929
sendBody = await Promise.race<boolean>([
3030
new Promise((resolve) => {
31-
timeoutId = Number(timing.setTimeout(resolve, Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
31+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
3232
}),
3333
new Promise((resolve) => {
3434
httpRequest.on("continue", () => {

0 commit comments

Comments
 (0)