fix: fall back to getRandomValues when crypto.randomUUID is unavailable - #1548
Merged
Conversation
crypto.randomUUID only exists in secure contexts (https or localhost). When Studio is served over plain HTTP on a non-localhost host (e.g. http://192.168.x.x:5555), staging a new row crashed with "TypeError: crypto.randomUUID is not a function". Route UUID generation through a shared helper that prefers the native crypto.randomUUID and otherwise builds an RFC 4122 UUIDv4 from crypto.getRandomValues, which is available in non-secure contexts. Fixes #1493 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: π Files selected for processing (4)
Summary by CodeRabbit
WalkthroughAdds a π₯ Pre-merge checks | β 5β Passed checks (5 passed)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
β¨ Simplify code
Comment |
Contributor
|
Compute preview deployed. Branch: |
This was referenced Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1493
crypto.randomUUIDonly exists in secure contexts (https / localhost). When Studio is served over plain HTTP on a LAN host (e.g.http://192.168.x.x:5555), the staged-row draft-id generator crashed the UI withTypeError: crypto.randomUUID is not a functionβ this is also the actually-breaking failure several users hit in the prisma/orm#29731 thread.Fix
New shared
randomUUID()helper (ui/lib/random-uuid.ts) that prefers nativecrypto.randomUUIDand falls back to an RFC 4122 UUIDv4 built fromcrypto.getRandomValues(available in non-secure contexts), with version/variant bits set explicitly. The single browser-facing call site inActiveTableViewnow uses it β an exhaustive grep of the browser-bundled entries found no others, and the bundled UUID deps (uuidv7,short-uuidwith the custom translator) never callrandomUUID.Verification
randomUUIDis undefined; version/variant bits verified deterministically.π€ Generated with Claude Code