Abort signal is not triggered

When I use this code, it doesn't trigger when user disconnects from the worker. But it shows an error X [ERROR] Uncaught (in promise) Error: Network connection lost. in the console somehow.
request.signal.addEventListener('abort', () => {
console.log(123)
});
request.signal.addEventListener('abort', () => {
console.log(123)
});
What's the problem?
6 Replies
AgentCord
AgentCordOP3mo ago
Is there any other way to detect if user disconnects?
James
James3mo ago
AFAIK, this isn't really possible with Workers, unless you're doing WebSockets or something similar.
AgentCord
AgentCordOP3mo ago
Oh...... Okay
Hello, I’m Allie!
I'm wondering, if you race a Promise that resolves in a certain amount of time against a Promise that resolves when aborted, then pass it into a waitUntil, it might work?
AgentCord
AgentCordOP3mo ago
Already using waitUntil() to check the state after some delay and the abort callback doesn't get called anyway
hfcRed
hfcRed3mo ago
From my own experience workers will continue running until they finish the request, even when the client aborts Not sure if this is true, but thats the behavior I'm getting
Want results from more Discord servers?
Add your server