Skip to content

tests: #807 — async-context tracking harness (ALS + async_hooks)#824

Merged
proggeramlug merged 2 commits into
mainfrom
worktree-fix-807-async-ctx-harness
May 16, 2026
Merged

tests: #807 — async-context tracking harness (ALS + async_hooks)#824
proggeramlug merged 2 commits into
mainfrom
worktree-fix-807-async-ctx-harness

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

New test-files/test_harness_async_context.ts covers the propagation rules AsyncLocalStorage + async_hooks need to follow, with eight independent sections each printing section: result:

  1. Sync run() store baseline.
  2. Single await to a separately-named async fn.
  3. Chained awaits (depth 8).
  4. queueMicrotask callback inside run().
  5. setTimeout(fn, 0) callback inside run().
  6. Nested run() with an await in each layer.
  7. Concurrent Promise.all of two runs (isolation, no cross-pollination).
  8. createHook lifecycle + executionAsyncId API shape.

What it surfaces today

Verified against node --experimental-strip-types (16 stable lines, all sections PASS). Perry v0.5.912 has partial support:

  • Pass: sections 1, 6, 7. Sync nested runs propagate correctly when getStore() is called inline in the run body, and concurrent isolation holds.
  • Fail: sections 2/3 (await to a separately-named async fn) and 4/5 (queueMicrotask, setTimeout) — store evaporates after the suspension; getStore() returns undefined.
  • Stub: section 8 — createHook returns undefined; API is name-only today.

That partial picture is itself the useful signal — the gap isn't all-or-nothing.

known_failures.json

Adds test_harness_async_context linked to #788 (AsyncLocalStorage real tracking) and #789 (async_hooks createHook lifecycle). Each section flips to PASS independently as those land.

Test plan

  • node --experimental-strip-types produces 16 stable lines.
  • perry compile && /tmp/out runs end-to-end, exits 0 (it doesn't crash — it just prints undefined for the failing sections), and the diff pins exactly which propagation rules are missing.
  • known_failures.json entry prevents the parity gate from flagging this as a new regression.

Closes #807.

…nc_hooks)

Eight independent sections probing the propagation rules Perry's
`AsyncLocalStorage` / `async_hooks` need to follow:

1. Sync `run()` store baseline.
2. Single `await` to a separately-named async fn.
3. Chained awaits (depth 8).
4. `queueMicrotask` callback inside `run()`.
5. `setTimeout(fn, 0)` callback inside `run()`.
6. Nested `run()` with an await in each layer (sync outer / inner).
7. Concurrent `Promise.all` of two runs (isolation, no cross-pollination).
8. `createHook` lifecycle + `executionAsyncId` API shape.

Node baseline (verified on Node v25.8): 16 stable lines, all sections
PASS. Perry today (v0.5.912):

- Sections 1, 6, and 7 already pass — sync nested runs and concurrent
  runs whose `getStore()` is called inline in the run body propagate
  correctly.
- Sections 2/3/4/5 print `undefined` instead of the trace — the store
  evaporates when the await continuation is in a separately-named async
  function, or when the resume comes from queueMicrotask / setTimeout.
- Section 8 — `createHook` returns undefined; the API is a name-only
  stub today.

`known_failures.json` adds an entry pointing at #788 (AsyncLocalStorage
real tracking) and #789 (async_hooks createHook lifecycle). Each section
flips to PASS independently as those land.
@proggeramlug proggeramlug merged commit 7a6b0f9 into main May 16, 2026
9 checks passed
@proggeramlug proggeramlug deleted the worktree-fix-807-async-ctx-harness branch May 16, 2026 05:22
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.

tests: harness for async context tracking

1 participant