Fix crypto.randomUUID is not a function#995
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical issue where the application failed to generate client-side IDs in non-HTTPS environments due to the unavailability of Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new generateClientId utility function to provide a robust method for generating unique client-side IDs. This utility includes fallbacks for crypto.randomUUID(), crypto.getRandomValues(), and a temporary ID generation if the crypto API is entirely unavailable. The new utility is integrated into the AddWorkoutPlanDialog and WorkoutPresetForm components, replacing direct calls to crypto.randomUUID(). Additionally, comprehensive unit tests for generateClientId have been added. The only feedback provided suggests improving the conciseness of the generateClientId function by directly modifying bytes[6] and bytes[8] instead of using intermediate variables and nullish coalescing, as Uint8Array elements are guaranteed to be numbers.
Tip
Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run
pnpm run validateto check for any errors.PRs that include tests and clear screenshots are highly preferred!
Description
Fix crypto.randomUUID is not a function error that occurs when accessing the web client without HTTPS. Note that localhost is not affected so this slipped by the dev team.
Related Issue
PR type [x] Issue [ ] New Feature [ ] Documentation
Linked Issue: #992
Checklist
Please check all that apply:
pnpm run validate(especially for Frontend).en) translation file (if applicable).rls_policies.sqlfor any new user-specific tables.Screenshots (if applicable)
Before
[Insert screenshot/GIF here]
After
[Insert screenshot/GIF here]