Skip to content

fix: drop uuid dependency so requests work on React Native#224

Open
roymiloh wants to merge 1 commit into
mainfrom
fix/react-native-uuid-crypto
Open

fix: drop uuid dependency so requests work on React Native#224
roymiloh wants to merge 1 commit into
mainfrom
fix/react-native-uuid-crypto

Conversation

@roymiloh

@roymiloh roymiloh commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to the React Native support work. uuid v13's v4() calls crypto.getRandomValues() internally, which React Native (Hermes) does not provide without the react-native-get-random-values polyfill — it throws crypto.getRandomValues() not supported. This ran on every request in the axios request interceptor (axios-client.ts), so all requests failed on React Native.

Fix

  • uuid was used in exactly one place: a requestId used only for in-iframe postMessage request/response correlation. It needs to be unique, not cryptographically random.
  • Replaced uuidv4() with the existing generateUuid() (Math.random-based, in common.ts, already used for session/anonymous ids) — works in every environment.
  • Dropped the uuid dependency entirely (package.json + lockfile), so the SDK no longer depends on crypto.getRandomValues and consumers don't need a polyfill.

Testing

  • New test drives a request with crypto stubbed to undefined (the RN condition) and asserts it resolves and still attaches a correlation id.
  • Lockfile change is only the uuid removal.
  • Full suite 168 passed; typecheck, type-tests, build, and lint all clean.

🤖 Generated with Claude Code

uuid v13's v4() calls `crypto.getRandomValues()`, which React Native
(Hermes) does not provide without the `react-native-get-random-values`
polyfill, so it throws `crypto.getRandomValues() not supported`. This
ran on every request in the axios interceptor, breaking all requests on
React Native.

The only use of uuid was a request-correlation id for in-iframe
postMessage logging, which needs to be unique, not cryptographically
random. Replace it with the existing `generateUuid()` (Math.random,
already used for session/anonymous ids) and drop the uuid dependency
entirely, so the SDK no longer requires a crypto polyfill.

Adds a test that drives a request with `crypto` unavailable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented Jul 8, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.37-pr.224.eb846f3

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.37-pr.224.eb846f3"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.37-pr.224.eb846f3"
  }
}

Preview published to npm registry — try new features instantly!

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.

2 participants