-
-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
On getting status code >= 400 from serever, retry handler throws an error which closes the open connection
Reproducible By
you will see here
New connection
connection closed
New connection
Hello World
const fastify = require("fastify");
const { RetryAgent, Agent } = require("undici");
const app = fastify();
let tries = 0;
app.get("/", (req, res) => {
if (++tries % 2 !== 0) {
return res.status(500).send("Test error");
}
res.send("Hello World");
});
app.server.on("connection", (socket) => {
console.log("New connection");
socket.on("close", () => {
console.log("connection closed");
});
});
async function start() {
await app.listen({ port: 3000 });
const a = new RetryAgent(new Agent({ connections: 1 }));
const res = await a.request({
origin: "http://localhost:3000",
path: "/",
method: "GET",
});
console.log(await res.body.text());
}
start();Expected Behavior
It will pass the error but will leave the connection open if its non-connection related error
Additional context
By destroying the socket it also prevents the user get the error body from response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working