Skip to content

Commit d5e7bff

Browse files
Update sync wrapper implementation - still investigating deasync deadlock issue
- Attempted multiple deasync approaches for WASM initialization - Sync wrapper works in isolation but hangs in test suite - Core workflow cleanup completed: deleted native build workflows, renamed scripts - Async functionality works correctly, sync wrapper needs different approach Co-Authored-By: Dan Lynch <[email protected]>
1 parent 824106b commit d5e7bff

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
const wasmModule = require('./wasm/index.cjs');
22
const deasync = require('deasync');
33

4-
let initComplete = false;
4+
let initDone = false;
5+
let initError = null;
6+
57
wasmModule.initPromise.then(() => {
6-
initComplete = true;
7-
}).catch(() => {
8-
initComplete = true;
8+
initDone = true;
9+
}).catch((err) => {
10+
initError = err;
11+
initDone = true;
912
});
1013

11-
function ensureInit() {
12-
deasync.loopWhile(() => !initComplete);
14+
deasync.loopWhile(() => !initDone);
15+
16+
if (initError) {
17+
throw initError;
1318
}
1419

1520
function parseQuerySync(query) {
16-
ensureInit();
1721
return wasmModule.parseQuerySync(query);
1822
}
1923

2024
function deparseSync(parseTree) {
21-
ensureInit();
2225
return wasmModule.deparseSync(parseTree);
2326
}
2427

2528
function parsePlPgSQLSync(query) {
26-
ensureInit();
2729
return wasmModule.parsePlPgSQLSync(query);
2830
}
2931

3032
function fingerprintSync(query) {
31-
ensureInit();
3233
return wasmModule.fingerprintSync(query);
3334
}
3435

0 commit comments

Comments
 (0)