fix: concurrent-safe debug tracing with AsyncLocalStorage#18
Merged
Conversation
…-safe debug tracing The previous push/pop parent stack was a global mutable array shared across all async contexts, causing corrupted parent attribution when multiple Task tools run in parallel. Replace with AsyncLocalStorage which gives each async continuation chain its own isolated context. - Add runWithDebugParent() using AsyncLocalStorage for context propagation - Move debugEnd/debugError outside parent context for correct indent level - Remove deprecated pushParent/popParent (no callers, not publicly exported) - Add 54 unit tests for debug module (previously zero coverage) - Update AGENTS.md documentation - Bump version to 0.5.2 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
parentStackarray withAsyncLocalStoragefor debug parent tracking, fixing corrupted parent attribution when multiple Task tools run in paralleldebugEnd/debugErroremission outside the parent context so the task's own end event renders at the correct indent level in human-readable outputpushParent/popParentfunctions (not publicly exported, zero callers)debug.ts(previously zero coverage), including parallel isolation regression tests