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
fetch signal abortcontroller does not work #2489
Comments
This appears to be a bug within the HTTPS (TLS?) connection code, where it waits for some initial handshake before allowing timeouts to interrupt the connection. I seen one of these fetches give up, even from a native timeout.
@Plecra This seems to also apply to plain HTTP connections. If the connection cannot be established (all packets dropped at the destination), signals do nothing. Only the internal HTTP timeout is applied (1 minute?). I tested const timeout = setTimeout(() => {
console.error('Signal failed!');
process.exit();
}, 2e3);
try {
console.log(await fetch('http://127.0.0.7', { signal: AbortSignal.timeout(1e3) }));
}
catch (e) {
clearTimeout(timeout);
if (e.name === 'TimeoutError') console.log('Signal worked!');
else console.error(e);
} I'm also pinging @cirospaciari, since he authored #6390 |
Weirdly if i let this run I get
// abort in 1 second
let controller = new AbortController();
setTimeout(() => controller.abort(), 1000);
console.time('fetch');
try {
let response = await fetch('http://192.168.1.134', {
signal: controller.signal,
});
// @ts-expect-error abc
} catch (err: Error) {
console.timeEnd('fetch');
if (err.name == 'AbortError') {
// handle abort()
console.info('Aborted!');
} else {
throw err;
}
} |
ignore me this doesnt work it just instantly times out. 😞
|
I'm in China and the firewall is blocking google.com, in my test code I guess fetch is not handling signal in the DNS resolution stage. I replaced google.com with a URL that is accessible and signal is fine! |
The issue happens on GitHub Actions as well, bun just timeout indefinitely even with |
What version of Bun is running?
0.5.8
What platform is your computer?
Darwin 22.3.0 arm64 arm
What steps can reproduce the bug?
What is the expected behavior?
It should take 100ms
What do you see instead?
It takes a lot longer!
Additional information
No response
The text was updated successfully, but these errors were encountered: