Skip to content

fix: import randomUUID from node crypto#800

Open
mturac wants to merge 1 commit into
rohitg00:mainfrom
mturac:fix/issue-715-randomuuid-node16
Open

fix: import randomUUID from node crypto#800
mturac wants to merge 1 commit into
rohitg00:mainfrom
mturac:fix/issue-715-randomuuid-node16

Conversation

@mturac
Copy link
Copy Markdown

@mturac mturac commented Jun 3, 2026

Summary

  • import randomUUID from node:crypto in the shared schema module
  • remove the bare global crypto.randomUUID() dependency from generated ids
  • keep the generated id format unchanged

Tests

  • git diff --check
  • npm test -- test/schema.test.ts
  • npm run build
  • ! rg -n "crypto\.randomUUID\(" dist

Closes #715

Summary by CodeRabbit

  • Chores
    • Updated internal ID generation implementation with no changes to functionality or user-facing behavior.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

@mturac is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd821084-4727-49fa-8351-19124240180d

📥 Commits

Reviewing files that changed from the base of the PR and between d442fee and 070bc57.

📒 Files selected for processing (1)
  • src/state/schema.ts

📝 Walkthrough

Walkthrough

src/state/schema.ts adds randomUUID to its node:crypto import and updates the generateId function to call the imported randomUUID() directly instead of crypto.randomUUID(), fixing compatibility with Node.js < 19.

Changes

Crypto Compatibility Fix

Layer / File(s) Summary
Update crypto import and generateId usage
src/state/schema.ts
The node:crypto import is updated to include randomUUID, and the generateId function is changed to call randomUUID() directly instead of accessing crypto.randomUUID() globally.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit hops through code so neat,
where randomUUID makes imports complete,
no more globals in the node—
just functions where the imports strode!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: importing randomUUID from node:crypto to fix Node.js <19 compatibility.
Linked Issues check ✅ Passed The PR addresses the core coding requirement from #715: importing randomUUID from node:crypto and updating generateId to use it.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to the stated objective: only modifying src/state/schema.ts to import and use randomUUID from node:crypto.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Bug: crypto.randomUUID() breaks on Node.js < 19

1 participant