Skip to content

Commit 8043529

Browse files
yasumorishimaclaude
andcommitted
fix: reset init promise on failure to allow retry
If wasmInit() fails (e.g. WASM load error), clear the cached promise so subsequent calls can retry instead of permanently returning the rejected promise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f4ae4ad commit 8043529

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/generate/rs.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ let initPromise: Promise<void> | undefined;
99

1010
export async function wasmInit(...args: Parameters<typeof init>) {
1111
if (!initPromise) {
12-
initPromise = init(...args).then(() => {});
12+
initPromise = init(...args).then(
13+
() => {},
14+
(error: unknown) => {
15+
initPromise = undefined;
16+
throw error;
17+
},
18+
);
1319
}
1420
return initPromise;
1521
}

0 commit comments

Comments
 (0)