In the following code, I’m forcing an error. GOT error
is printed on console so the program is going in catch block, but express never sends a response with statusCode 500.
app.get("/", async (req, res) => {
try {
res.setHeader("Cache-control", `public, max-age=${maxAge}`);
await pipeline(got.stream(someUrl), res);
} catch (error) {
if (error instanceof RequestError) {
console.error("GOT Error", error.message);
} else {
console.error("Some other Error", (error as Error).message);
}
res.sendStatus(500);
}
});
Here is a screenshot from client
Expected result: express should send response with statusCode 500.