We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a98ebac commit a2261e9Copy full SHA for a2261e9
1 file changed
packages/core/src/v3/isomorphic/friendlyId.ts
@@ -39,7 +39,11 @@ function loadNodeWebCrypto(): Crypto | undefined {
39
}
40
41
42
-const getRandomValues: RandomFiller = resolveGetRandomValues();
+// Resolve the crypto source lazily on first use (memoized), so merely importing this
43
+// widely-used module never throws when crypto is unavailable — only minting a KSUID would.
44
+let cachedGetRandomValues: RandomFiller | undefined;
45
+const getRandomValues: RandomFiller = (array) =>
46
+ (cachedGetRandomValues ??= resolveGetRandomValues())(array);
47
48
/** Encode raw bytes as base62 (big-endian), left-padded to the given length. */
49
function base62Encode(bytes: Uint8Array, length: number): string {
0 commit comments