@massalabs/gossip-sdk 0.0.2-dev.20260223110530 → 0.0.2-dev.20260223124034

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/db/sqlite.js +21 -6
  2. package/package.json +1 -1
package/dist/db/sqlite.js CHANGED
@@ -128,12 +128,27 @@ export async function initDb(options = {}) {
128
128
  });
129
129
  db.worker.onmessage = handleWorkerMessage;
130
130
  db.useWorker = true;
131
- await postToWorker({
132
- type: 'init',
133
- opfsPath: options.opfsPath,
134
- wasmUrl: options.wasmUrl,
135
- initSql: PRAGMAS,
136
- });
131
+ try {
132
+ await postToWorker({
133
+ type: 'init',
134
+ opfsPath: options.opfsPath,
135
+ wasmUrl: options.wasmUrl,
136
+ initSql: PRAGMAS,
137
+ });
138
+ }
139
+ catch (err) {
140
+ // Prevent dangling worker and "another open Access Handle" on retry:
141
+ // only one SyncAccessHandle per file is allowed (e.g. another tab or
142
+ // a previous failed init may hold it). Terminate and reset so retry
143
+ // doesn't create a second worker.
144
+ if (db.worker) {
145
+ db.worker.terminate();
146
+ db.worker = null;
147
+ }
148
+ db.useWorker = false;
149
+ db.pending.clear();
150
+ throw err;
151
+ }
137
152
  }
138
153
  else {
139
154
  // In-memory mode (tests): sync WASM build, in-process, fast, isolated.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/gossip-sdk",
3
- "version": "0.0.2-dev.20260223110530",
3
+ "version": "0.0.2-dev.20260223124034",
4
4
  "description": "Gossip SDK for automation, chatbot, and integration use cases",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",