Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RetryAgent doesn't keep the event loop alive #3975

Closed
blinsay opened this issue Dec 30, 2024 · 2 comments · Fixed by #3977
Closed

RetryAgent doesn't keep the event loop alive #3975

blinsay opened this issue Dec 30, 2024 · 2 comments · Fixed by #3977
Labels
bug Something isn't working

Comments

@blinsay
Copy link

blinsay commented Dec 30, 2024

Bug Description

When using RetryAgent, Node exits while there are pending retries in flight.

Reproducible By

I've been playing around in a brand new node project with only unidici installed and trying to run the following script. This is mostly copy/pasted from the docs - I don't think I'm doing anything unorthodox here.

import { request, Agent, RetryAgent } from "undici";

const resp = await request("http://httpbin.org/status/418", {
  dispatcher: new RetryAgent(new Agent(), {
    statusCodes: [418],
  }),
  headers: { "User-Agent": "teapot" },
});

console.log("status:", resp.statusCode);
console.log("headers:", resp.headers);

Expected Behavior

I'd expect to get either an HTTP response or a retry error.

Logs & Screenshots

$ node example.js; echo "exit code: $status"
Warning: Detected unsettled top-level await at file:///[redacted]/example.js:3
const resp = await request("http://httpbin.org/status/418", {
             ^



exit code: 13

Additional context

$ node --version
v23.5.0
$ grep undici package.json
    "undici": "^7.2.0"
@blinsay blinsay added the bug Something isn't working label Dec 30, 2024
@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@blinsay
Copy link
Author

blinsay commented Dec 31, 2024

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

It's not obvious to me what's wrong, or I would have sent one already! From skimming the RetryAgent code I can't tell why Node would decide the task queue is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants