File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,17 @@ import { wasm, withThreadPool } from './bindings/js/node/node-backend.js';
33
44let Snarky , Ledger , Pickles , Test_ ;
55let isInitialized = false ;
6+ let initializingPromise ;
67
78async function initializeBindings ( ) {
89 if ( isInitialized ) return ;
9- isInitialized = true ;
10+ if ( initializingPromise ) {
11+ await initializingPromise ;
12+ return ;
13+ }
1014 let snarky ;
15+ let resolve ;
16+ initializingPromise = new Promise ( ( r ) => ( resolve = r ) ) ;
1117
1218 // this dynamic import makes jest respect the import order
1319 // otherwise the cjs file gets imported before its implicit esm dependencies and fails
@@ -18,6 +24,9 @@ async function initializeBindings() {
1824 await import ( './bindings/compiled/_node_bindings/o1js_node.bc.cjs' )
1925 ) . default ;
2026 ( { Snarky, Ledger, Pickles, Test : Test_ } = snarky ) ;
27+ resolve ( ) ;
28+ initializingPromise = undefined ;
29+ isInitialized = true ;
2130}
2231
2332async function Test ( ) {
You can’t perform that action at this time.
0 commit comments