Repository navigation
fix(lint): flag crypto.randomUUID() as non-deterministic code - #7325
Closed
rezamuliawijaya wants to merge 1 commit into
Closed
rezamuliawijaya wants to merge 1 commit into
rezamuliawijaya wants to merge 1 commit into
Conversation
The render shim seeds getRandomValues only, so a composition calling crypto.randomUUID() lints clean but still produces a different UUID on every render and in every worker. Reproduce: compose a script that calls crypto.randomUUID(), lint it — no non_deterministic_code finding appears even though the value diverges across renders, the same symptom Math.random and crypto.getRandomValues are flagged for.
2 of 4 tasks
Collaborator
|
Thanks for contributing this fix. I reviewed the competing submissions and selected #7322, which includes the same runtime fix with a regression test that also pins its seeded-PRNG guidance. Closing this as a duplicate so the issue has one implementation to take through CI and merge: #7322. This is consolidation of overlapping work, not a rejection of your contribution. |
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.
What
Adds
crypto.randomUUIDto thenon_deterministic_coderule's pattern list inpackages/lint/src/rules/core.ts, with a test incore.test.ts.Why
The render shim seeds
getRandomValuesonly (packages/producer/src/services/fileServer.ts), socrypto.randomUUID()stays random between renders and workers. A composition using it lints clean today while still producing a different UUID on every render — the same symptomMath.randomandcrypto.getRandomValuesare already flagged for.Related work
Fixes #7276
How
One pattern entry in the rule's pattern list, grouped with the sibling
crypto.getRandomValuesentry and carrying a comment explaining why it is non-deterministic even though the shim seeds entropy. The hint mirrors the existing randomness guidance (seeded PRNG), matching the assertion style of the neighboring test.Test plan
detects crypto.randomUUID() in script content;bun test packages/lint/src/rules/core.test.tspasses 200/200