Skip to content

Commit 7518b78

Browse files
mjunaidcaclaude
andcommitted
debug(org-switch): Add 100ms delay after setActive before OAuth flow
Adds a small delay to test if there's a race condition between session.activeOrganizationId being updated and the OAuth flow reading it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7361a5a commit 7518b78

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

apps/web/src/components/OrgSwitcher.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export function OrgSwitcher() {
6969
const result = await organization.setActive({ organizationId: orgId })
7070
console.log("[OrgSwitcher] setActive result:", result)
7171

72+
// Small delay to ensure session is committed to database
73+
// before starting OAuth flow (workaround for potential race condition)
74+
await new Promise(resolve => setTimeout(resolve, 100))
75+
7276
// Step 2: Re-authenticate to get new JWT with updated tenant_id
7377
// The SSO will read the updated activeOrganizationId from session
7478
// and include it as tenant_id in the new JWT

0 commit comments

Comments
 (0)