Skip to content

fix: Bound async state serialization so a blocked thread can't freeze or crash - #44

Closed
timfish wants to merge 1 commit into
getsentry:mainfrom
johannespinger:fix/bounded-async-state-serialization
Closed

timfish wants to merge 1 commit into
getsentry:mainfrom
johannespinger:fix/bounded-async-state-serialization

Conversation

@timfish

@timfish timfish commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

Testing @johannespinger patch

SanitizeForJSON walked the AsyncLocalStorage state without any limits while the captured thread was interrupted. Shared references were copied once per path, linked structures (e.g. Node timer lists reachable from a Sentry client) recursed once per node with an O(depth) cycle check, and exceptions from the walk escaped into the interrupted JavaScript.

  • Limit depth (10), entries per container (1000), values read (20000) and string length (1 MiB); cut data is replaced by visible markers
  • Copy own enumerable string keys only, into null-prototype containers so inherited toJSON hooks can't bypass the limits
  • Replace Proxies by "[Proxy]" without running traps
  • Catch exceptions during state serialization and keep V8 execution termination

… or crash

SanitizeForJSON walked the AsyncLocalStorage state without any limits while the captured thread was interrupted. Shared references were copied once per path, linked structures (e.g. Node timer lists reachable from a Sentry client) recursed once per node with an O(depth) cycle check, and exceptions from the walk escaped into the interrupted JavaScript.

- Limit depth (10), entries per container (1000), values read (20000) and string length (1 MiB); cut data is replaced by visible markers
- Copy own enumerable string keys only, into null-prototype containers so inherited toJSON hooks can't bypass the limits
- Replace Proxies by "[Proxy]" without running traps
- Catch exceptions during state serialization and keep V8 execution termination
@timfish

timfish commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator Author

Failing tests fixed in #45

@timfish timfish closed this Oct 12, 2026
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.

serialization possible freezes the capturing thread

2 participants