Skip to content

test(integration): wait for the CLI child to exit before the lazy-recovery test resolves - #4432

Closed
cpacker wants to merge 1 commit into
mainfrom
bc4/test-home-cleanup-ebusy
Closed

cpacker wants to merge 1 commit into
mainfrom
bc4/test-home-cleanup-ebusy

Conversation

@cpacker

@cpacker cpacker commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

API / windows-latest / 4 has been failing on main with the same error on four pushes since 2026-09-13 20:53 UTC (889987b, 690c6dd, 232d320, b100c2d) and twice on #4431:

(pass) lazy approval recovery > handles concurrent message while approval is pending
error: EBUSY: resource busy or locked, rm C:\Users\RUNNER~1\AppData\Local\Temp\letta-code-test-home-xxxxxx
      at cleanup (scripts/test-home-preload.ts:70:5)
(fail) (unnamed)

The test itself passes. runLazyRecoveryTest resolved its promise the moment the final result frame arrived and scheduled proc.kill() 500 ms later. The test-home preload's afterAll runs rmSync(testHome) as soon as the test resolves, so it races the still-running CLI child, which holds files under that HOME. Windows refuses to remove a directory with open handles; Linux and macOS let it go.

Fix: record the outcome when the result frame arrives, but resolve the promise from the child's close handler, which fires after the child's stdio has closed. The 500 ms grace-then-kill stays. The fallback for a child that exits on its own (resolve from whatever it produced) is unchanged.

Verification

  • bun run typecheck and biome on the file.
  • The test cannot run in this sandbox (the CLI's --new-agent startup returns 404 Agent not found under the sandbox key on main as well), so the live check is this PR's API workflow, which runs this file on Linux, macOS, and Windows. I will report the Windows shard result.

Breadcrumbs

AI Disclosure

  • This pull request was written entirely by a human
  • This pull request was written with AI assistance and reviewed and edited by a human
  • I have read the AI Policy and agree to its terms

AI Tool(s) Used

Letta Code

Human Verification

I have reviewed and understand every change in this pull request and take responsibility for its correctness.

…overy test resolves

The test resolved its promise as soon as the final result frame arrived and
killed the spawned CLI 500 ms later. The test-home preload removes the temp
HOME in afterAll right after the test resolves, while the child still holds
files there; on Windows that rm fails with EBUSY (API / windows-latest / 4 on
four main pushes 2026-09-13/14). Resolve from the "close" handler instead.

Co-Authored-By: Charles Packer <5475622+cpacker@users.noreply.github.com>

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
@letta-integration

Copy link
Copy Markdown
Contributor

This exact child-exit cleanup change is now on main through #4453 (merge 6304454), also included in #4452. Verified the file on current main matches this PR’s fix. Closing this redundant PR; no additional merge is needed.

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.

1 participant