Repository navigation
fix(test): gateway publication suite fails Windows teardown with EBUSY - #127201
Conversation
The harness removed its fixture root while a per-agent SQLite handle opened under it was still cached, so the transcript-report restart case failed in teardown on Windows instead of in an assertion. Closing the agent cache after the shared state database only moves the lock, because the agent close releases leases through shared state and reopens it. Ordering the two closes the way the zalo and zalouser fixtures already do releases every handle before the removal, with no retry budget needed.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 1:02 PM ET / 17:02 UTC. ClawSweeper reviewWhat this changesThis PR makes the gateway GitHub-publication test harness close cached per-agent SQLite databases before shared state and temporary-directory cleanup, preventing Windows EBUSY teardown failures. Merge readinessThe focused test-harness repair remains necessary: current main still closes shared state before removing the fixture directory, while the per-agent cache releases its lease through shared state. The proposed ordering matches an established sibling teardown pattern and has independent native-Windows before/after proof. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherGateway publication tests use temporary shared and per-agent SQLite state while exercising publication and restart behavior. The harness teardown must release both cache layers before Windows deletes the fixture directory. flowchart LR
A[Publication test] --> B[Temporary state directory]
B --> C[Shared state database]
B --> D[Per-agent database cache]
D --> E[Release lease through shared state]
E --> F[Close shared state]
F --> G[Remove fixture directory]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4. Total +4 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the explicit agent-cache then shared-state teardown sequence, preserving a deterministic cleanup boundary rather than masking the live handle with filesystem retries. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: current main retains the teardown ordering, and two independent native-Windows before/after runs in the PR show the exact suite changing from EBUSY failures to passing. Is this the best way to solve the issue? Yes. Closing the agent cache before shared state follows the actual lease-release ownership path and established sibling fixture ordering; retrying directory deletion would only conceal the leaked handle. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 70c2be7e6aab. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
Independently reproduced on a second Windows box using your exact command: 3 failed / 60 passed (63) on base blob |
|
Thanks for running it — that is the confirmation this needed. Two machines, two Node patch One thing changed while you were reproducing: #126352 merged on 21 August. It repaired eight Nothing further is needed from your side — CI is green and the review bot has this at |
|
Merged via squash.
|
openclaw#127201) The harness removed its fixture root while a per-agent SQLite handle opened under it was still cached, so the transcript-report restart case failed in teardown on Windows instead of in an assertion. Closing the agent cache after the shared state database only moves the lock, because the agent close releases leases through shared state and reopens it. Ordering the two closes the way the zalo and zalouser fixtures already do releases every handle before the removal, with no retry budget needed.
What Problem This Solves
Contributors on Windows cannot run
src/gateway/github-publication.test.tsto green: one casefails in teardown with
EBUSY, never in an assertion. The shared harness removes its temporarystate directory while a per-agent SQLite handle opened underneath it is still cached. On Linux
unlinking an open file succeeds, so CI never sees it.
The failing case is
projects an accepted worker publication exactly once across transcript-report restart. It fails three times per run becausevitest.gateway.config.tsruns the file under each of
gateway-core,gateway-client, andgateway-server.Why This Change Was Made
installGitHubPublicationTestHarness()closes the shared state database and then removes thefixture root, but the transcript-report path opens a per-agent database under that root and
closeOpenClawStateDatabaseForTest()does not release it.Adding
closeOpenClawAgentDatabasesForTest()after the shared-state close does not fix it —it only moves the lock to
state\openclaw.sqlite-wal. The agent close releases leases throughshared state, so closing shared state first lets the agent close reopen it, leaving a fresh
handle that nothing closes. This is the ordering the zalo and zalouser fixtures already document
and use, at
extensions/zalouser/src/ingress.test-support.ts:79-86:The neighbouring file in this same directory already teardowns in the correct order —
src/gateway/github-publication-transcript.test.ts:13-16— and it covers the same transcriptreporter that the failing case restarts. One of the two files covering this feature got the
ordering; the harness did not.
Tests only; no production file is touched.
User Impact
Contributors on Windows can run the gateway GitHub publication suites to completion instead of
reading a teardown failure that has nothing to do with the code under test. Behavior on Linux
and macOS is unchanged, and no
fs.rmretry budget is added, so nothing is masked by retries.Evidence
Windows 11, Node v24.18.1, both arms on the same tree —
origin/main9050d9b0a79and thattree with only this one file patched.
origin/main9050d9b0a79EBUSY ... unlink ...\agents\main\agent\openclaw-agent.sqlite@MohammedAlkindi, who reported this file, independently reproduced both arms on a second
Windows host with the same command - 3 failed / 60 passed (63) on base blob
079cf082ba8a1,63 passed (63) with the ordering applied - on Node v24.18.0 rather than v24.18.1, so the two
runs are independent on the runtime as well:
#127201 (comment)
The ordering is the whole fix. Measured separately at
587c7524e58, with the two calls in thereverse order the run stays red and the lock simply moves:
rm(as shipped)agents\main\agent\openclaw-agent.sqlitermstate\openclaw.sqlite-walrmrmwithmaxRetries: 20, retryDelay: 25The last two rows are the same result, so the retry budget is not load-bearing here and is
deliberately left out of this change.
Both files that import the patched harness, run together on this branch:
->
6 passed (6)files,150 passed (150)tests../node_modules/.bin/tsgo -p test/tsconfig/tsconfig.core.test.gateway-root.json --noEmit-> exit 0./node_modules/.bin/oxlint src/gateway/github-publication.test-support.ts-> exit 0./node_modules/.bin/oxfmt --check src/gateway/github-publication.test-support.ts-> exit 0Out of scope, recorded so it is not attributed to this class: on the same base
src/gateway/github-publication-git-index.test.tsfails 24 cases on Windows with zeroEBUSY— every one isfatal: unable to access '//./nul': Invalid argumentfromcore.hooksPath=${os.devNull}. That is a different Windows defect and this branch does nottouch it.
Relationship to the other repairs for #119796
This is disjoint from the other repairs for #119796 and can land in any order relative to them.
extensions/for thissame class, adding
closeOpenClawAgentDatabasesForTest()before fixture removal in three ofthem (
alibaba,codex,openai) andresetPluginStateStoreForTests()in the rest. None ofthose fixtures also close shared state, so the ordering question did not arise there; here it
does, and the order used is the one the zalo and zalouser fixtures already document.
extensions/zalouser/.src/gateway/github-publication.test-support.ts, and is the firstinstance of this class reported outside
extensions/. It was surfaced by @MohammedAlkindi in[Bug]: Windows: vitest teardown fails with EBUSY unlink on agent state DB (openclaw-agent.sqlite handle not released) #119796 (comment); the ordering
diagnosis and the measurements above are in the reply at
[Bug]: Windows: vitest teardown fails with EBUSY unlink on agent state DB (openclaw-agent.sqlite handle not released) #119796 (comment), which the reporter
confirmed in [Bug]: Windows: vitest teardown fails with EBUSY unlink on agent state DB (openclaw-agent.sqlite handle not released) #119796 (comment).
No
src/gatewaytest appears in the hardcoded Windows CI file lists, so nothing upstream wouldhave surfaced this.
AI-assisted.