fix(test): settle fake checkpoint writer so main-slice test drains cleanly#25
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efcf6bc83a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| yield* Effect.addFinalizer(() => | ||
| Effect.sync(() => { | ||
| if (spawnRef.current === impl) spawnRef.current = undefined | ||
| if (spawnRef.current === impl) spawnRef.current = previousSpawnRef |
There was a problem hiding this comment.
Avoid restoring disposed spawn refs
When two Actor.layer scopes overlap but do not shut down in strict LIFO order, this can resurrect a finalized service: scope A installs implA, scope B captures it and installs implB, A finalizes first and does nothing because current !== implA, then B finalizes and restores the now-disposed implA. Consumers such as checkpoint writer spawning read spawnRef.current later, and a stale actor service can attempt to forkIn A's closed scope. Consider tracking active entries/removing this impl from a stack rather than restoring a single saved pointer.
Useful? React with 👍 / 👎.
…eanly The recording actor's spawn outcome never resolved, so tryStartCheckpointWriter's settlement-watcher fiber stayed suspended and was force-interrupted at scope close — a flaky source under it.live. Settle the outcome so the watcher runs to completion (writers.delete) and assert the writer drains to "no-writer". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
efcf6bc to
946b80b
Compare
|
Reverted the |
|
CI note — the red
|
Summary
checkpoint-main-slicetest: the recording actor's spawn outcome never resolved,leaving
tryStartCheckpointWriter's settlement-watcher fiber suspended until scopeclose force-interrupted it — a flaky source under
it.live. Settle the outcome sothe watcher completes (
writers.delete) and assert the writer drains tono-writer.No production change —
actor/spawn.tsis untouched; the test's spawn-ref finalizerstays
= undefined, consistent with the sibling checkpoint tests.Relation to upstream
Same change set as XiaomiMiMo#1400 (fork → upstream), shared head branch.
Verification (local)
bun typecheck— exit 0bun test test/session/checkpoint-main-slice.test.ts— 1 pass / 13 assertions🤖 Generated with Claude Code