Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
Browser extension pairing and relay-token initialization can reject an empty key file that another process has exclusively created but is still writing, instead of adopting that first writer's completed key.
Steps to reproduce
- Create an isolated temporary state/credentials directory; do not use an operator's credentials or Gateway.
- In one process, exclusively open
browser-extension-relay.secretwith mode0600, leaving the file empty and the descriptor open. - While that writer is paused, call the real
ensureExtensionRelayTokenowner from another process using the isolated state directory. Repeat separately through the realbuildBrowserExtensionPairingpath. - Finish writing a synthetic valid relay key through the original descriptor after the second process starts.
Expected behavior
The initialization/pairing call adopts the first writer's completed key within the existing bounded handoff. It must retain the writer's file identity and must not overwrite malformed persistent credentials. This is the first-writer-wins contract already implemented for competing exclusive creates and the documented automatic/manual pairing flow: https://docs.openclaw.ai/tools/chrome-extension.
Actual behavior
Both isolated reproductions reject in approximately 1 ms with FsSafeError code invalid-path and a message that the relay-secret file is empty. The writer then completes successfully without changing the inode. The owner fails before entering its bounded exclusive-create handoff; pairing additionally reads the key during config resolution before it reaches the owner.
OpenClaw version
Source build 19762af88e31f1502b6fe969514035142dd25087 (manifest 2026.8.1), installed @openclaw/fs-safe 0.5.6. The affected owner and test blobs are identical at base 8dac217ce94e14a67ad2fc65837e518a2fbe0669. Stable-release exposure has not been established.
Operating system
macOS 27.0; Node.js 24.19.0.
Install method
Source checkout with repository-pinned pnpm dependencies.
Model
Not applicable: this is filesystem and browser-pairing initialization, with no model invocation.
Provider / routing chain
Not applicable: isolated local credential writer and browser plugin owner/pairing calls; no external provider or live Gateway.
Logs
scenario: writer-created-before-ensure
adopted: false
elapsedMs: 1
sameInode: true
finalTokenUnchanged: true
failure.code: invalid-path
failure.message: browser extension relay secret file at <synthetic-state>/credentials/browser-extension-relay.secret is empty.
Screenshots, recordings, and evidence
The installed dependency's dist/secret-file.js:114-160 rejects existing empty files; dist/pinned-write.js:117-145 publishes the exclusive-created final name before its asynchronous write. OpenClaw's default filesystem mode uses that fallback. Real owner and pairing regressions both failed before the local repair, without mocking the SDK or touching live credentials.
Impact and severity
Concurrent first-use pairing/relay initialization can fail instead of returning the shared key. The ordering reproduces deterministically with an already-open empty file; its frequency in production is not measured. No credential replacement or data loss was observed.
Additional information
Related: #128379 — the larger standalone-relay feature separately repaired the read inside its EEXIST loop. This report covers the pre-existing first read and earlier config/lifecycle reads, not a regression introduced by that feature. A focused repair is being prepared independently so the feature can reuse the canonical fix.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Aug 27, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 27, 2026, 3:31 AM ET / 07:31 UTC.
Summary
This remains necessary: current main can reject an initializing relay secret before its existing bounded first-writer handoff, and the protected
maintainerlabel requires explicit maintainer handling rather than automated closure or repair dispatch.Reproducibility: yes. from source: create and hold an empty relay-secret file, then invoke the real pairing or relay owner; the synchronous safe read occurs before the bounded handoff. This review did not execute it because dependencies are absent in the read-only checkout.
Root-cause cluster
Relationship:
canonicalCanonical: #130784
Summary: This issue is the canonical remaining pre-read/configuration race; the linked relay-daemon PR repairs only an overlapping later EEXIST handoff.
Members:
partial_overlap: feat(browser): standalone extension relay daemon with native-host wake-up #128379 - Its stated repair retains bounded rereading after an exclusive-create collision, while this issue identifies earlier reads that prevent reaching that path.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
The protected
maintainerlabel keeps this verified bug out of automated repair dispatch; it needs the owner-level dependency-contract check before implementation.Review details
Best possible solution:
Keep strict rejection for persistent malformed credentials, but centralize first-writer initialization-state handling in the Browser relay-secret owner so configuration, pairing, and relay lifecycle cannot bypass the bounded adoption path.
Do we have a high-confidence way to reproduce the issue?
Yes, from source: create and hold an empty relay-secret file, then invoke the real pairing or relay owner; the synchronous safe read occurs before the bounded handoff. This review did not execute it because dependencies are absent in the read-only checkout.
Is this the best way to solve the issue?
Yes, provided the repair preserves strict rejection of persistent malformed credentials and fixes the state classification at the relay-secret owner rather than adding caller-specific retries.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 0c5fb0f7ac94.
Label changes
Label changes:
P2: A deterministic concurrent first-use failure blocks Browser pairing or relay startup, but reported production frequency is unmeasured and no loss of credentials was observed.impact:auth-provider: The broken state is the host-local secret that authenticates the Browser extension relay and is consumed by pairing.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.Label justifications:
P2: A deterministic concurrent first-use failure blocks Browser pairing or relay startup, but reported production frequency is unmeasured and no loss of credentials was observed.impact:auth-provider: The broken state is the host-local secret that authenticates the Browser extension relay and is consumed by pairing.Evidence reviewed
What I checked:
secret-existsbounded reread loop can run. (extensions/browser/src/browser/extension-relay/relay-auth.ts:56, 0c5fb0f7ac94)extensions/browser/src/browser/extension-pairing.ts:65, 0c5fb0f7ac94)src/infra/secret-file.test.ts:89, 0c5fb0f7ac94)extensions/browser/src/browser/extension-relay/relay-auth.ts:52, d77e2a5876b9)secret-exists; it does not remove the current main pre-read or the configuration-time read identified above. (extensions/browser/src/browser/extension-relay/relay-auth.ts:68, 0c5fb0f7ac94)Likely related people:
extensions/browser/src/browser/extension-relay/relay-auth.ts,extensions/browser/src/browser/config.ts,extensions/browser/src/browser/extension-pairing.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.steipete commentedon Aug 27, 2026
Fixed by PR #130832 — concurrent first-use extension pairing, merged as dd005e53866f.
Failed reads now stay in the bounded, validated adoption path, including an in-progress key reached through an existing credentials-directory alias. Creating a missing key through a symlinked directory still rejects, and malformed persistent credentials are not replaced. The earlier config/lifecycle reads that could fail before reaching the owner were removed.
Verified with failed-before/passed-after real-file regressions, 184 passing focused/sibling tests (one Windows-only skip), type/lint checks, a canonical runtime-artifact build, and successful exact-head CI. The built public CLI paired in 11.093 seconds within the unchanged 30-second bound, preserving the synthetic key, inode, and mode. All 12 landed files match the reviewed candidate. The separate developer source-launcher timeout remains a named tooling follow-up; it is not claimed fixed by this PR.