refactor(adapters): use Web Crypto randomUUID instead of node:crypto (2/2)#19504
refactor(adapters): use Web Crypto randomUUID instead of node:crypto (2/2)#19504ediskandarov wants to merge 1 commit into
Conversation
Part 2/2 of the repo-wide unification (stores/, agent-sdks/, pubsub/, mastracode/, workflows/, voice/, signals/, server-adapters/, observability/). Same mechanical change as part 1: drop randomUUID from node:crypto imports and call the identical Web Crypto global, removing an unnecessary Node-only module dependency that breaks V8-isolate bundling. Fixes mastra-ai#19501 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 002b9a3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 38 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@ediskandarov is attempting to deploy a commit to the Mastra Team on Vercel. A member of the Team first needs to authorize it. |
PR triageLinked issue check passed (#19501). Mastra uses CodeRabbit for automated code reviews. Please address all feedback from CodeRabbit by either making changes to your PR or leaving a comment explaining why you disagree with the feedback. Since CodeRabbit is an AI, it may occasionally provide incorrect feedback. PR complexity score
Applied label: Changed test gateChanged Test Gate is pending. The |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (84)
WalkthroughChangesWeb Crypto UUID migration
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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. Comment |
|
Closing: pivoting to package-scoped PRs per review feedback. Will re-submit per package after the @mastra/core slice. |
Description
Part 2 of 2 of the repo-wide UUID unification (split from #19502, which exceeded the 150-file review limit; part 1 covers
packages/*). This part coversstores/*,agent-sdks/*,pubsub/*,mastracode/,workflows/inngest,voice/*,signals/github,server-adapters/nestjs, andobservability/— 83 files.Same mechanical change and rationale as part 1: drop
randomUUIDfromnode:crypto/cryptoimports and call the identical Web Crypto global, removing an unnecessary Node-only module dependency that breaks bundling for V8-isolate runtimes (Convex default runtime, Cloudflare Workers withoutnodejs_compat). Follows the@mastra/convexfix in #19498.One non-trivial spot: the datasets storage domains in
stores/mongodb,stores/mysql, andstores/spannerpassedrandomUUIDas a function reference toplanDatasetItemBatch; those now pass() => crypto.randomUUID().Related issue(s)
Fixes #19501
Type of change
Testing
randomUUID-from-crypto imports in the covered directories (repo-wide grep).pnpm turbo buildfor@mastra/mongodb,@mastra/mysql,@mastra/spanner,@mastra/openaiand their dependency graphs: clean (this caught and verified the function-reference fix above).@internal/test-utils/setupstubs the globalcrypto.randomUUID.AI disclosure
Implemented with Claude Code (Fable 5) as a reviewed codemod; human-reviewed.
🤖 Generated with Claude Code
ELI5
We replaced Node-specific UUID generation with the browser-compatible Web Crypto version across the codebase. This helps the same code run in edge environments like Cloudflare Workers and Convex without extra Node compatibility settings.
Summary
crypto.randomUUID().node:cryptoAPIs.randomUUIDimports.