Skip to content

fix(browser): dedupe concurrent relay init and await shared startup promise (AI-assisted)#21277

Closed
HOYALIM wants to merge 2 commits intoopenclaw:mainfrom
HOYALIM:codex/pr-browser-relay-init-dedupe
Closed

fix(browser): dedupe concurrent relay init and await shared startup promise (AI-assisted)#21277
HOYALIM wants to merge 2 commits intoopenclaw:mainfrom
HOYALIM:codex/pr-browser-relay-init-dedupe

Conversation

@HOYALIM
Copy link
Contributor

@HOYALIM HOYALIM commented Feb 19, 2026

Summary

  • Problem: Concurrent relay initialization on the same port could race and produce flaky startup/error behavior.
  • Why it matters: Browser extension relay startup reliability suffers under concurrent calls.
  • What changed: Added shared per-port init coordination and ensured callers await the same startup lifecycle; added/updated relay tests.
  • What did NOT change (scope boundary): Did not alter relay auth model (gateway-token flow remains unchanged).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Browser extension relay startup is more deterministic under concurrent initialization.
  • Reduced startup race flakiness when multiple callers initialize relay simultaneously.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS (local dev)
  • Runtime/container: Node.js + pnpm
  • Model/provider: N/A (unit tests)
  • Integration/channel (if any): Browser extension relay
  • Relevant config (redacted): OPENCLAW_GATEWAY_TOKEN set in tests

Steps

  1. Start relay initialization concurrently for the same requested port.
  2. Verify both callers resolve coherently to shared init outcome.
  3. Run relay test suite.

Expected

  • No startup race flake for concurrent same-port init.
  • Deterministic completion/failure propagation to all callers.

Actual

  • Verified by passing relay tests after patch.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: extension relay concurrent init behavior.
  • Edge cases checked: same-port concurrent startup path.
  • What you did not verify: full browser-extension E2E across all platforms.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert this PR commits.
  • Files/config to restore: browser relay files touched in this PR.
  • Known bad symptoms reviewers should watch for: relay startup hangs or inconsistent concurrent startup outcomes.

Risks and Mitigations

  • Risk: Shared init promise lifecycle bug could stall startup in edge cases.
    • Mitigation: explicit resolve/reject path and test coverage on concurrent startup scenario.

Greptile Summary

Added shared promise coordination to deduplicate concurrent relay initialization on the same port. When multiple callers attempt to start a relay server simultaneously, subsequent callers now await the shared initialization promise instead of creating race conditions. The implementation properly handles both success and error propagation to all waiting callers, with cleanup guaranteed via finally blocks.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean implementation of concurrent initialization deduplication with proper error handling, cleanup logic, and test coverage. The promise coordination pattern correctly leverages JavaScript's single-threaded event loop to prevent races. No breaking changes or risky refactoring.
  • No files require special attention

Last reviewed commit: 50342e0

steipete added a commit that referenced this pull request Feb 26, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR #21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
@steipete
Copy link
Contributor

Landed on main via 5416cabdf.

What landed:

SHA mapping:

  • original PR commits: 1d36cbb00770d025637c21be65b8906c29d063e9, 50342e06ee2dbc103a3844cf79fee4d3b3420d6d
  • landed commit: 5416cabdf

Thanks for the fix, @HOYALIM.

@steipete steipete closed this Feb 26, 2026
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
mylukin pushed a commit to mylukin/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
wanjizheng pushed a commit to wanjizheng/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
(cherry picked from commit a480e3b)
vincentkoc pushed a commit to Sid-Qin/openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
vincentkoc pushed a commit to rylena/rylen-openclaw that referenced this pull request Feb 28, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
steipete added a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
thebenjaminlee pushed a commit to escape-velocity-ventures/openclaw that referenced this pull request Mar 7, 2026
Add shared per-port relay initialization dedupe so concurrent callers await a single startup lifecycle, with regression coverage and changelog entry.
Landed from contributor @HOYALIM (PR openclaw#21277).

Co-authored-by: Ho Lim <subhoya@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants