Skip to content

fix(app): make client ID generation resilient to UUID failures#297

Open
Jacobinwwey wants to merge 2 commits intogetpaseo:mainfrom
Jacobinwwey:fix/app-client-id-fallback
Open

fix(app): make client ID generation resilient to UUID failures#297
Jacobinwwey wants to merge 2 commits intogetpaseo:mainfrom
Jacobinwwey:fix/app-client-id-fallback

Conversation

@Jacobinwwey
Copy link
Copy Markdown

1. Context & Motivation (Context)

  • Issue: N/A
  • Problem: The app currently assumes globalThis.crypto.randomUUID() is always usable when minting a client ID. On some React Native / Expo setups the UUID path can be broken or recurse through an incomplete polyfill, which turns first-run client ID creation into a hard failure instead of a recoverable fallback.
  • Trade-offs: This change keeps randomUUID() as the preferred entropy source, but falls back to getRandomValues() when UUID generation is broken. That adds a small amount of local formatting logic in exchange for a more robust startup path without changing the persisted client ID shape.

2. Implementation Details (Implementation)

  • Updated client-id generation to catch randomUUID() failures and derive the persisted identifier from getRandomValues() before falling back to the existing time/Math-based path.
  • Updated the Expo crypto polyfill to synthesize randomUUID() from getRandomValues() so environments that already expose a working random byte source do not depend on a second UUID implementation.
  • Added regression coverage for both the client ID path and the crypto polyfill path.
  • Note: This intentionally avoids any Metro / Expo workspace resolution changes. The PR is limited to runtime fallback behavior and its tests.

3. Testing Strategies (Validation)

  • Added Unit Tests for client-id (covering randomUUID() failure fallback)
  • Added Unit Tests for polyfillCrypto (covering non-recursive UUID generation from getRandomValues())
  • Ran npm run test --workspace=@getpaseo/app -- src/utils/client-id.test.ts src/polyfills/crypto.test.ts
  • Ran npm run build:highlight && npm run typecheck --workspace=@getpaseo/app
  • Verified backward compatibility with the existing cid_<hex> storage format

Signed-off-by: Jacobinwwey <jacob.hxx.cn@outlook.com>
Signed-off-by: Jacobinwwey <jacob.hxx.cn@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant