Skip to content

Redeem a proxy connect return once under StrictMode - #1884

Closed
michielbdejong wants to merge 1 commit into
developfrom
claude/proxy-return-strictmode
Closed

michielbdejong wants to merge 1 commit into
developfrom
claude/proxy-return-strictmode

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Closes #1883

In a Vite dev build, React StrictMode runs ProxyConnectReturn's effect twice. The first run consumed the pending handoff and started redeeming, and then its cleanup cancelled the redirect. The second run found no handoff and showed "This connection return is not one this browser started."

Fix. redeemOnce keeps one in-flight redemption per integration_state in a module-level map. The second effect run awaits the first run's promise and redirects when it resolves. A settled entry stays for 10 s, so a remount right after it resolves still gets the result, and is then dropped. A return this browser never started still errors, and a failed redemption is attempted and shown once. Production builds were not affected.

Test. ProxyConnectReturn.test.tsx renders the component inside <React.StrictMode>, with ProxyConnections mocked and location stubbed. It checks four things:

  • redemption runs once, the redirect happens, and no alert is shown;
  • a failed redemption runs once and its error is shown;
  • an unknown or already-consumed return still shows "not one this browser started";
  • a page load that is not a return renders its children.

Before the fix, the first two tests failed: replace was never called, and finish was called twice.

Checked: the chunks/AppPage and proxyConnections vitest suites, typecheck and lint all pass. No UI change, so no screenshots.

Pin candidate. ProxyConnectReturn.tsx also exists on claude/atomic-plugins-pin-candidate14, where the effect calls finishProxyReturn(store, connections, params) (it returns returnTo) instead of connections.finish(params). This commit does not apply cleanly there: git merge-tree reports a content conflict in the effect. The resolution is mechanical. Keep redeemOnce and, inside it, call finishProxyReturn(store, connections, params) in place of connections.finish(params).then(({ returnTo }) => returnTo). The new test works unchanged there, because its mocked finish result carries no recordOnInstallation. The fix should go into the next pin candidate.

🤖 Generated with Claude Code

In dev, StrictMode ran ProxyConnectReturn's effect twice. The first run
consumed the pending handoff and was cancelled before redirecting; the
second found no handoff and showed "This connection return is not one
this browser started." Share one redemption per integration_state so the
second run awaits the first and redirects.

Closes #1883

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joepio

joepio commented Sep 30, 2026

Copy link
Copy Markdown
Member

Trekmeester: included in batch #1915 (run 36779344325). It lands with it when green; if this PR's own tests fail there, I take it out and say why here.

@joepio

joepio commented Sep 30, 2026

Copy link
Copy Markdown
Member

Trekmeester: included in batch #1947 (run 36781515104; #1915 had been merged without it). It lands when that run is green; if this PR breaks something there, I take it out and say why here.

joepio added a commit that referenced this pull request Oct 1, 2026
… e2e traces, Android menus, demo tooling, docs (#1947)

Includes #1884, #1930, #1940, #1888, #1933, #1882, #1834, #1631, #1932, #1945 and the ForkBar part of #1530.

joepio commented Oct 1, 2026

Copy link
Copy Markdown
Member

Merged into develop through batch #1947 (squash 1f892aa); this head was verified as part of it. Closing.


Generated by Claude Code

@joepio joepio closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

browser bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App connect return fails in dev builds: ProxyConnectReturn redeems twice under StrictMode

2 participants