Skip to content

fix: properly cleanup setTimeout when scheduler.wait gets aborted#6068

Merged
LuisDuarte1 merged 3 commits intomainfrom
lduarte/cleanup-aborted-scheduler-waits
Feb 13, 2026
Merged

fix: properly cleanup setTimeout when scheduler.wait gets aborted#6068
LuisDuarte1 merged 3 commits intomainfrom
lduarte/cleanup-aborted-scheduler-waits

Conversation

@LuisDuarte1
Copy link
Contributor

Even though scheduler.wait can be passed an AbortSignal, when this signal is actioned it doesn't seem to properly cleanup the setTimeout. This is most troubling when the aborted scheduler.wait has to wait for a good while, because that setTimeout slot will probably never be freed up.

The repro test emulates 11k setTimeouts being aborted - and before that would fail with:

workerd/io/worker.c++:2324: info: uncaught exception; source = Uncaught (in promise); stack = QuotaExceededError: You have exceeded the number of active timeouts you may set. max active timeouts: 10000, current active timeouts: 10000, finished timeouts: 0

And now it passes because it correctly cancels the setTimeout.

Even though `scheduler.wait` can be passed an `AbortSignal`, when this
signal is actioned it doesn't seem to properly cleanup the setTimeout.
This is most troubling when the aborted `scheduler.wait` has to wait for
a good while, because that `setTimeout` slot will probably never be
freed up.

The repro test emulates 11k setTimeouts being aborted - and before that
would fail with:

```
workerd/io/worker.c++:2324: info: uncaught exception; source = Uncaught (in promise); stack = QuotaExceededError: You have exceeded the number of active timeouts you may set. max active timeouts: 10000, current active timeouts: 10000, finished timeouts: 0
```

And now it passes because it correctly cancels the setTimeout.
@LuisDuarte1 LuisDuarte1 requested review from a team as code owners February 13, 2026 11:21
Co-authored-by: James M Snell <jsnell@cloudflare.com>
@LuisDuarte1 LuisDuarte1 merged commit 463132d into main Feb 13, 2026
22 of 23 checks passed
@LuisDuarte1 LuisDuarte1 deleted the lduarte/cleanup-aborted-scheduler-waits branch February 13, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants