Conversation
Member
|
I would also add to the description that async work in an abort signal callback can have coroutine-like behavior, as in, they can interlace work instead of waiting for the first cleanup task to completely finish. |
masad-frost
reviewed
Feb 24, 2026
masad-frost
reviewed
Feb 25, 2026
|
|
||
| const deferCleanup = (fn: () => void | Promise<void>) => { | ||
| if (cleanupsHaveRun) { | ||
| void runCleanupSafe(fn); |
Member
There was a problem hiding this comment.
I guess these are gonna be outside of traces
Member
Author
There was a problem hiding this comment.
yeah i was debating adding a separate span for this but decided against it
masad-frost
approved these changes
Feb 25, 2026
Member
|
Yayy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ctx.signal.addEventListener('abort', ...)runs after the procedure span so procedures that do things like hold a lock for the duration of the proc drop the lock before cleanup runsalso, abort signal order is FIFO when instead cleanup should generally be LIFO (a la Go
defer)ultimately this reveals a bigger issue which is that we are conflating cancellation with cleanup
What changed
add ctx.deferCleanup
Versioning