Skip to content

Commit

Permalink
fix(node-http-handler): rejoin on error in writeRequestBody (#4880)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Jun 24, 2023
1 parent e5d4fa8 commit 6c8730a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/node-http-handler/src/node-http-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,24 @@ describe("NodeHttpHandler", () => {
expect(spy.mock.calls.length).toBe(0);
});

it(`won't throw uncatchable error in writeRequestBody`, async () => {
const nodeHttpHandler = new NodeHttpHandler();

await expect(
nodeHttpHandler.handle(
new HttpRequest({
hostname: "localhost",
method: "GET",
port: (mockHttpsServer.address() as AddressInfo).port,
protocol: "https:",
path: "/",
headers: {},
body: {},
})
)
).rejects.toHaveProperty("name", "TypeError");
});

it("will destroy the request when aborted", async () => {
const mockResponse = {
statusCode: 200,
Expand Down
2 changes: 1 addition & 1 deletion packages/node-http-handler/src/node-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class NodeHttpHandler implements HttpHandler {
});
}

writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout);
writeRequestBodyPromise = writeRequestBody(req, request, this.config.requestTimeout).catch(_reject);
});
}
}

0 comments on commit 6c8730a

Please sign in to comment.