Replies: 1 comment
-
By default, the import { createServer } from "node:http"
import { once } from "node:events"
import { RetryAgent, Agent, fetch } from "./index.js";
const server = createServer((req, res) => {
setTimeout(() => {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end('Hello World');
}, 1000)
})
server.listen();
await once(server, 'listening')
const agent = new RetryAgent(new Agent({ headersTimeout: 500 }), {
errorCodes: ['UND_ERR_HEADERS_TIMEOUT'],
});
const { port } = server.address()
const res = await fetch(`http://localhost:${port}`, {
dispatcher: agent,
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried to use fetch with RetryAgent, but it doesn't seem to work well.
When a
HeadersTimeoutError
occurs, it does not retry the request but instead throws the error.Does the
fetch
supportsRetryAgent
?Beta Was this translation helpful? Give feedback.
All reactions