Skip to content

fix(uuid): fall back when crypto.randomUUID is unavailable#1158

Merged
ananaBMaster merged 2 commits intomainfrom
fix/issue-1157-randomuuid
Mar 18, 2026
Merged

fix(uuid): fall back when crypto.randomUUID is unavailable#1158
ananaBMaster merged 2 commits intomainfrom
fix/issue-1157-randomuuid

Conversation

@frogGuaGuaGuaGua
Copy link
Copy Markdown
Collaborator

@frogGuaGuaGuaGua frogGuaGuaGuaGua commented Mar 18, 2026

Type of Changes

  • ✨ New feature (feat)
  • 🐛 Bug fix (fix)
  • 📝 Documentation change (docs)
  • 💄 UI/style change (style)
  • ♻️ Code refactoring (refactor)
  • ⚡ Performance improvement (perf)
  • ✅ Test related (test)
  • 🔧 Build or dependencies update (build)
  • 🔄 CI/CD related (ci)
  • 🌐 Internationalization (i18n)
  • 🧠 AI model related (ai)
  • 🔄 Revert a previous commit (revert)
  • 📦 Other changes that do not modify src or test files (chore)

Description

  • add a shared getRandomUUID() helper that falls back to crypto.getRandomValues() when crypto.randomUUID() is unavailable
  • route extension UUID creation through that helper so startup no longer depends on entrypoint/polyfill ordering
  • add regression tests for helper fallback and DEFAULT_CONFIG import with a getRandomValues-only crypto implementation

Related Issue

Closes #1157

How Has This Been Tested?

  • Added unit tests

  • Verified through manual testing

  • SKIP_FREE_API=true pnpm exec vitest run src/utils/__tests__/crypto-polyfill.test.ts src/utils/constants/__tests__/config.test.ts src/utils/config/__tests__/init.test.ts src/utils/server/edge-tts/__tests__/signature.test.ts src/entrypoints/selection.content/selection-toolbar/custom-action-button/__tests__/use-custom-action-execution.test.ts

  • pnpm exec tsc --noEmit

  • pnpm build

  • remote push hook: nx run @read-frog/extension:lint, nx run @read-frog/extension:type-check, nx run @read-frog/extension:test (75 files, 789 tests passed)

Screenshots

  • Not applicable

Checklist

  • I have tested these changes locally
  • I have updated the documentation accordingly if necessary
  • My code follows the code style of this project
  • My changes do not break existing functionality
  • If my code was generated by AI, I have proofread and improved it as necessary.

Additional Information

  • The forwarded screenshot does not prove the runtime was iPad-specific; this fix treats it as a general extension compatibility issue.

Summary by cubic

Add a shared getRandomUUID() that falls back to crypto.getRandomValues() when crypto.randomUUID() is missing, and remove the global randomUUID polyfill. All UUIDs now use the helper to avoid crashes and brittle startup ordering; closes #1157.

  • Bug Fixes
    • Routed all UUID creation through getRandomUUID() (analytics, TTS, translation, queues, content scripts, YouTube subtitles, backups, provider/config/custom action flows).
    • Stopped injecting crypto.randomUUID globally; the helper only requires getRandomValues.
    • Added tests for the helper and DEFAULT_CONFIG initialization without randomUUID, and verified the module does not patch crypto.randomUUID.

Written for commit d02da69. Summary will update on new commits.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 18, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: d02da69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@read-frog/extension Patch

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

@github-actions github-actions bot added the fix label Mar 18, 2026
@dosubot dosubot bot added the app: browser extension Related to browser extension label Mar 18, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 22 files

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 18, 2026
@ananaBMaster ananaBMaster merged commit 18c10b6 into main Mar 18, 2026
6 of 7 checks passed
@ananaBMaster ananaBMaster deleted the fix/issue-1157-randomuuid branch March 18, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: browser extension Related to browser extension fix lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] crypto.randomUUID() 缺失会导致扩展初始化报错

2 participants