Skip to content

Hub script throws "Missing app id" during initialization race condition #40

Description

@leonelgalan

Bug

The Rownd Hub script (hub.rownd.io/static/scripts/rph.mjs) throws an unhandled
"Missing app id" error during initialization when mainReducer dispatches a state
update before app_id has been loaded from the API.

Stack trace

Error: Missing app id
  at getPassphrase (src/scripts/storage/crypto/utils.ts:9)
  at deriveKey (src/scripts/storage/crypto/utils.ts:46)
  at encrypt (src/scripts/storage/crypto/crypto.ts:9)
  at setItem (src/scripts/storage/crypto/index.ts:18)
  at updateStorage (src/scripts/Context.tsx:60)
  at mainReducer (src/scripts/Context.tsx:742)
  at <anonymous> (src/scripts/DefaultContext.tsx:126)

Reproduction

Navigate to any page with @rownd/react RowndProvider mounted. The error occurs
intermittently on initial page load — it's a race between the hub script dispatching
its first state update and the API response that provides app_id.

We see ~85 occurrences across ~77 users over the past 24 days (web only, via
@rownd/[email protected] which delegates to @rownd/[email protected] on web).

Impact

  • Functional: None — in-memory state works fine; only encrypted storage
    persistence fails for that cycle
  • Observability: Unhandled promise rejection pollutes error tracking (PostHog,
    Sentry, etc.)

Suggested fix

Guard updateStorage in mainReducer to no-op when app_id is not yet available,
rather than letting getPassphrase() throw. The state will be persisted on the next
dispatch after app_id is loaded.

Workaround

We're filtering this error in our PostHog before_send pipeline to suppress the noise.

Versions

  • @rownd/react: 1.5.3
  • @rownd/react-native: 4.0.2
  • Browsers: Chrome, Safari (desktop + mobile)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions