the moveWhileDestinationIsEdited test helper should wait for the script when its editor fails #141

Closed
opened 2026-10-10 03:57:38 +00:00 by jercik · 0 comments
Owner

At 1a85c77, the moveWhileDestinationIsEdited test helper can throw before it awaits the script. The calling test then deletes the fixture while the script is still running.

The helper starts the script (running, line 485), then opens an editor connection with a 5 s busy timeout and runs BEGIN IMMEDIATE (lines 490-493). If that fails with a lock error, or the edit statement throws, the finally closes the editor and the exception propagates. return await running (line 500) is never reached.

Its three callers (lines 1918, 1939 and 1966) remove the fixture in their own finally. A script still running against a removed fixture can make rmSync fail with ENOTEMPTY or leave the run hanging.

The sibling helper moveWithHistoryEditAfterStateCopy (lines 504-524) awaits running in its finally (line 521). It has that guard because its test showed this failure while #133 was in review: a lock error in the helper, then ENOTEMPTY on fixture removal. The same guard in moveWhileDestinationIsEdited would close the gap.

Evidence: code read. Not reproduced in 20 parallel runs.

At `1a85c77`, the `moveWhileDestinationIsEdited` test helper can throw before it awaits the script. The calling test then deletes the fixture while the script is still running. [The helper](https://code.j4k.dev/j4k-oss/agent-skills/src/commit/1a85c77277b4f8924278686aa2c2969477c4eece/skills/move-codex-session/scripts/move-codex-session.test.ts#L479-L501) starts the script (`running`, line 485), then opens an editor connection with a 5 s busy timeout and runs `BEGIN IMMEDIATE` (lines 490-493). If that fails with a lock error, or the edit statement throws, the `finally` closes the editor and the exception propagates. `return await running` (line 500) is never reached. Its three callers (lines 1918, 1939 and 1966) remove the fixture in their own `finally`. A script still running against a removed fixture can make `rmSync` fail with `ENOTEMPTY` or leave the run hanging. The sibling helper `moveWithHistoryEditAfterStateCopy` (lines 504-524) awaits `running` in its `finally` (line 521). It has that guard because its test showed this failure while #133 was in review: a lock error in the helper, then `ENOTEMPTY` on fixture removal. The same guard in `moveWhileDestinationIsEdited` would close the gap. Evidence: code read. Not reproduced in 20 parallel runs.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
j4k-oss/agent-skills#141
No description provided.