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

AbortSignal.timeout and fetch not working when can't reach server #13302

Open
kravetsone opened this issue Aug 14, 2024 · 9 comments
Open

AbortSignal.timeout and fetch not working when can't reach server #13302

kravetsone opened this issue Aug 14, 2024 · 9 comments
Labels
bug Something isn't working confirmed bug We can reproduce this issue web:fetch

Comments

@kravetsone
Copy link

What version of Bun is running?

1.1.24

What platform is your computer?

Linux 5.15.0-117-generic x86_64 x86_64

What steps can reproduce the bug?

const url = "https://some-url.com";

try {
  const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
  console.log(res);
  // …
} catch (err) {
  if (err.name === "TimeoutError") {
    console.error("Timeout: It took more than 5 seconds to get the result!");
  } else if (err.name === "AbortError") {
    console.error(
      "Fetch aborted by user action (browser stop button, closing tab, etc.",
    );
  } else if (err.name === "TypeError") {
    console.error("AbortSignal.timeout() method is not supported");
  } else {
    // A network error, or some other problem.
    console.error(`Error: type: ${err.name}, message: ${err.message}`);
  }
}

But it works correctly when i run it by node

image

I can't ping via shell it too

ping (this url)

and nothing is happend

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@kravetsone kravetsone added bug Something isn't working needs triage labels Aug 14, 2024
@kravetsone
Copy link
Author

issue still exists on 1.0.0, 1.1.15 so its not regression

@cirospaciari
Copy link
Member

cirospaciari commented Aug 14, 2024

Thank you for the report, if you can provide some extra information can help us to findout the problem, here is some questions:

1 - Are you using proxy or VPN?
2 - Did you tried another DNS like google or cloudflare?
3 - Did you test another URLs or is with all URLs? sometimes if you can providing the url causing the problem can help to reproduce here.
4 - The URL is always https? do http urls works fine?
5 - Are you using self signed certificates or extra CAs?

@kravetsone
Copy link
Author

Thank you for the report, if you can provide some extra information can help us to findout the problem, here is some questions:

1 - Are you using proxy or VPN? 2 - Did you tried another DNS like google or cloudflare? 3 - Did you test another URLs or is with all URLs? sometimes if you can providing the url causing the problem can help to reproduce here. 4 - The URL is always https? do http urls works fine? 5 - Are you using self signed certificates or extra CAs?

1 - No
2 - How can i do it safely?
3 - The url is - https://securepay.tinkoff.ru/v2

It accepts requests, but does not accept them from my server (apparently it blocks traffic by mistake). The rest of the requests (to another servers) are working properly.

4 - I test only with this https url
5 - No

@kravetsone kravetsone changed the title AbortSignal,timeout and fetch bug when i cant react server AbortSignal,timeout and fetch bug when i cant reach server Aug 15, 2024
@cirospaciari
Copy link
Member

We did some improvements when connecting to a address in canary can you try bun upgrade --canary and se if is still happening in this case?
My guess is we are failing in the resolution (IPV4/IPV6 choice) and timing out instead of giving a error like connection refused or similar.

@kravetsone
Copy link
Author

kravetsone commented Aug 15, 2024

We did some improvements when connecting to a address in canary can you try bun upgrade --canary and se if is still happening in this case?
My guess is we are failing in the resolution (IPV4/IPV6 choice) and timing out instead of giving a error like connection refused or similar.

Thanks for your work!
I'm happy that you try to help me)
But i tried canary version and issue still exists
IMG_20240815_222335_705.jpg

@Josh-Cena
Copy link

Josh-Cena commented Aug 16, 2024

I think this is the same problem. Minimal repro:

const startTime = Date.now();

fetch("https://creativejs.com/", { signal: AbortSignal.timeout(3000) }).then(console.log, () => {
  const endTime = Date.now();
  console.log(`Time taken: ${endTime - startTime}ms`);
});

In Node v22, it takes 3003ms; in Bun 1.1.24, it hangs.

(The website doesn't exist in HTTPS, but that's what I'm trying to programmatically verify via the timeout.)

@kravetsone
Copy link
Author

I think this is the same problem. Minimal repro:

const startTime = Date.now();

fetch("https://creativejs.com/", { signal: AbortSignal.timeout(3000) }).then(console.log, () => {
  const endTime = Date.now();
  console.log(`Time taken: ${endTime - startTime}ms`);
});

In Node v22, it takes 3003ms; in Bun 1.1.24, it hangs.

(The website doesn't exist in HTTPS, but that's what I'm trying to programmatically verify via the timeout.)

Yeah, really!
Thanks for more great reproduction
Screenshot_2024-08-17-00-05-04-08_3d419158bad5872c40592a6c9956e692.jpg

@kravetsone
Copy link
Author

update

@emersonlaurentino
Copy link

any update about it?

@RiskyMH RiskyMH added web:fetch confirmed bug We can reproduce this issue and removed needs triage labels Nov 20, 2024
@RiskyMH RiskyMH changed the title AbortSignal,timeout and fetch bug when i cant reach server AbortSignal.timeout and fetch not working when can't reach server Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue web:fetch
Projects
None yet
Development

No branches or pull requests

5 participants