Skip to content

Automate browser based workflows with AI

fallback to nanoid when crypto fails (#2845)

LawyZheng7a96642c12f4
diff --git a/skyvern-frontend/src/store/useClientIdStore.ts b/skyvern-frontend/src/store/useClientIdStore.ts
index b31e4dd9b..8fc815454 100644
--- a/skyvern-frontend/src/store/useClientIdStore.ts
+++ b/skyvern-frontend/src/store/useClientIdStore.ts
@@ -1,10 +1,20 @@
import { create } from "zustand";
+import { nanoid } from "nanoid";
type ClientIdStore = {
clientId: string;
};
-const initialClientId = crypto.randomUUID();
+const generateClientId = (): string => {
+ try {
+ return crypto.randomUUID();
+ } catch (error) {
+ // if crypto.randomUUID() fails, use nanoid as a fallback
+ return nanoid();
+ }
+};
+
+const initialClientId = generateClientId();
export const useClientIdStore = create<ClientIdStore>(() => ({
clientId: initialClientId,