Skip to content

Commit 1932a06

Browse files
committed
fix(web): isolate OAuth popups per flow across tabs
The popup used a fixed window name ("posthog-code-oauth"), so a second tab starting sign-in before the first finished could reuse and navigate away the first tab's popup. The first flow's callback then never fired, and the shared BroadcastChannel only carried the second flow's state, so the first tab waited until the five-minute timeout. Name each popup uniquely per flow (suffixing the per-flow OAuth state) so concurrent sign-ins open independent windows. State-based callback routing over the shared channel already delivers each callback to its own flow. Generated-By: PostHog Code Task-Id: d5bcaf27-c54b-45d5-920d-cc4f65c9e9fb
1 parent d2df278 commit 1932a06

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

apps/web/src/web-oauth-flow.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ export class WebOAuthFlowService implements IAuthOAuthFlowService {
112112
kind === "signup" ? buildSignupUrl(region, authUrl) : authUrl;
113113

114114
// Open before any network round-trip so the click's transient activation
115-
// still permits the popup.
115+
// still permits the popup. The window name is unique per flow: a fixed
116+
// name lets a concurrent sign-in in another tab reuse (and navigate away)
117+
// this flow's popup, stranding it until the timeout — its own callback
118+
// never fires and the shared channel only carries the other flow's state.
116119
const popup = window.open(
117120
target.toString(),
118-
"posthog-code-oauth",
121+
`posthog-code-oauth-${state}`,
119122
POPUP_FEATURES,
120123
);
121124
if (!popup) {

0 commit comments

Comments
 (0)