Skip to content

fix(test): gateway publication suite fails Windows teardown with EBUSY - #127201

Merged
steipete merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/gateway-publication-windows-teardown
Aug 23, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/gateway-publication-windows-teardown

Conversation

@Yigtwxx

@Yigtwxx Yigtwxx commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Contributors on Windows cannot run src/gateway/github-publication.test.ts to green: one case
fails in teardown with EBUSY, never in an assertion. The shared harness removes its temporary
state 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.

Error: EBUSY: resource busy or locked, unlink
  'C:\...\Temp\openclaw-publication-FOQReU\agents\main\agent\openclaw-agent.sqlite'

The failing case is projects an accepted worker publication exactly once across transcript-report restart. It fails three times per run because vitest.gateway.config.ts
runs the file under each of gateway-core, gateway-client, and gateway-server.

Why This Change Was Made

installGitHubPublicationTestHarness() closes the shared state database and then removes the
fixture 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 through
shared 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:

Agent close releases leases through shared state; closing shared state first can reopen it
during teardown and leave Windows handles under the state dir.

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 transcript
reporter 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.rm retry budget is added, so nothing is masked by retries.

Evidence

Windows 11, Node v24.18.1, both arms on the same tree — origin/main 9050d9b0a79 and that
tree with only this one file patched.

node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts \
  --configLoader runner src/gateway/github-publication.test.ts
arm result
origin/main 9050d9b0a79 3 failed / 60 passed (63) — EBUSY ... unlink ...\agents\main\agent\openclaw-agent.sqlite
this branch 63 passed (63)

@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 the
reverse order the run stays red and the lock simply moves:

teardown order result
state close -> rm (as shipped) 3 failed, lock on agents\main\agent\openclaw-agent.sqlite
state close -> agent close -> rm 3 failed, lock on state\openclaw.sqlite-wal
agent close -> state close -> rm 63 passed
agent close -> state close -> rm with maxRetries: 20, retryDelay: 25 63 passed

The 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:

node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts --configLoader runner \
  src/gateway/github-publication.test.ts src/gateway/github-publication-boundaries.test.ts

-> 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 0

Out of scope, recorded so it is not attributed to this class: on the same base
src/gateway/github-publication-git-index.test.ts fails 24 cases on Windows with zero
EBUSY — every one is fatal: unable to access '//./nul': Invalid argument from
core.hooksPath=${os.devNull}. That is a different Windows defect and this branch does not
touch 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.

No src/gateway test appears in the hardcoded Windows CI file lists, so nothing upstream would
have surfaced this.

AI-assisted.

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.
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Aug 21, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 1:02 PM ET / 17:02 UTC.

ClawSweeper review

What this changes

This 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 readiness

⚠️ Ready for maintainer review - 1 item remains

The 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
Reviewed head: e3751777d1fd460f7455882f5f5f97b74d7c6998

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow owner-aligned repair with two independent Windows reproductions, focused validation, and no review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR contains native Windows terminal before/after evidence for the affected suite, independently repeated on a second host with a different Node patch release.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR contains native Windows terminal before/after evidence for the affected suite, independently repeated on a second host with a different Node patch release.
Evidence reviewed 6 items Current-main gap: Current main still closes only shared state and then removes the temporary fixture root; it does not close the per-agent cache first.
Owner-boundary cause: Closing an agent database releases its cached lease through a shared-state write transaction, so agent caches must close while the shared-state handle remains available.
Existing sibling invariant: The Zalouser ingress fixture already closes agent databases before shared state and explains that reversing the order can reopen a Windows handle under the state directory.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts --configLoader runner src/gateway/github-publication.test.ts

Result: FAIL (partial) — step 2 expect_output 63 passed: expected terminal output was not visible within 30 seconds: "63 passed"

node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts --configLoader runner src/gateway/github-publication.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127201-mKCOdr/target$ node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts --configLoa
der runner src/gateway/github-publication.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts --configLoader runner src/gateway/github-publication.test.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127201-mKCOdr/target

 ✓  gateway-core  ../../src/gateway/github-publication.test.ts (21 tests) 4720ms
     ✓ publishes through exact HTTPS and replays the durable terminal result  574ms
     ✓ resumes after 'commit' without duplicating completed publication steps  355ms
     ✓ resumes after 'push' without duplicating completed publication steps  354ms
     ✓ resumes after 'pull request' without duplicating completed publication steps  349ms
     ✓ projects an accepted worker publication exactly once across transcript-report restart  497ms






































Assertions:

  • FAIL expect_output: 63 passed

How this fits together

Gateway 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]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed because the reviewed patch has no actionable finding; it is ready for ordinary maintainer merge handling.
Agent review details

Security

None.

PR surface

Source +4. Total +4 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 4 0 +4
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 0 +4

Review metrics

Metric Value Why it matters
Production versus test-support LOC production +0/-0; test support +4/-0 The change is confined to the teardown harness and adds no runtime product behavior.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This repairs a deterministic Windows contributor test-workflow failure without changing production runtime behavior.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR contains native Windows terminal before/after evidence for the affected suite, independently repeated on a second host with a different Node patch release.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR contains native Windows terminal before/after evidence for the affected suite, independently repeated on a second host with a different Node patch release.

Evidence

What I checked:

Likely related people:

  • Yigtwxx: Authored this teardown hunk and the related merged Windows fixture repair, so has demonstrated ownership of this cache-lifecycle failure class. (role: current hunk author and related repair contributor; confidence: medium; commits: e3751777d1fd, ff83e3efe811; files: src/gateway/github-publication.test-support.ts)
  • MohammedAlkindi: Independently reproduced the failing and passing Windows arms for this exact suite and originally surfaced the affected test path. (role: independent reproducer; confidence: high; files: src/gateway/github-publication.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-21T13:49:46.971Z sha e375177 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T15:36:14.324Z sha e375177 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T15:49:20.503Z sha e375177 :: needs maintainer review before merge. :: none

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

Independently reproduced on a second Windows box using your exact command: 3 failed / 60 passed (63) on base blob 079cf082ba8a1, and 63 passed (63) with the ordering applied. Windows 11, Node v24.18.0 rather than 24.18.1, so the two runs are independent on the runtime as well. This is the file I reported in #119796, and your ordering resolves it from my side.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 22, 2026
@Yigtwxx

Yigtwxx commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for running it — that is the confirmation this needed. Two machines, two Node patch
releases (24.18.0 and 24.18.1), the same base blob 079cf082ba8a1 and the same two arms, so the
result is not tied to one box's antivirus, filesystem, or runtime build. Your run is now in the
PR body under Evidence.

One thing changed while you were reproducing: #126352 merged on 21 August. It repaired eight
extensions/ fixtures for this same class, three of them (alibaba, codex, openai) by
adding closeOpenClawAgentDatabasesForTest() before the fixture removal, the rest by adding
resetPluginStateStoreForTests(). None of those fixtures also close shared state, so the
ordering question never came up there; here it does, and the order used is the one the zalo and
zalouser fixtures already document. The body now records that as well.

Nothing further is needed from your side — CI is green and the review bot has this at
ready-for-maintainer with no findings, so it is waiting on maintainer handling.

@steipete
steipete merged commit 60ae513 into openclaw:main Aug 23, 2026
194 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@Yigtwxx
Yigtwxx deleted the fix/gateway-publication-windows-teardown branch August 23, 2026 15:39
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants