thatcher 1.0.42 → 1.0.44

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/package.json +1 -1
  2. package/src/index.js +26 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thatcher",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "A config-driven application framework for building data-intensive web apps without code.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -248,7 +248,32 @@ export class Thatcher {
248
248
  _server = null;
249
249
  }
250
250
  for (const w of _hotReloadWatchers) w.close();
251
- _hotReloadWatchers = [];
251
+ _hotReloadWatchers = []
252
+ // This never called the underlying database client's own close() at all
253
+ // -- busybase's createEmbedded() now exposes a real one (busybase's own
254
+ // embedded.ts fix), but nothing here called it, so a consumer reusing the
255
+ // SAME database file in the same process (a fresh Thatcher instance, a
256
+ // test harness) would silently open a SECOND native handle onto an
257
+ // already-open file rather than genuinely replacing the first --
258
+ // _databaseInitialized is a MODULE-level singleton (see initDatabase()'s
259
+ // own comment / AGENTS.md's documented cwd-bound handle caveat), so it
260
+ // must be reset here too or a subsequent initDatabase() call would
261
+ // silently skip re-opening and keep using the now-closed client.
262
+ // NOTE (live-witnessed, Windows): calling close() does NOT synchronously
263
+ // release the native libsql binding's OS-level file lock while THIS
264
+ // process keeps running -- the lock only actually clears once the owning
265
+ // process exits. A caller needing the underlying file/directory removable
266
+ // in the SAME still-running process (e.g. a per-run isolated-tmpdir test
267
+ // harness) cannot rely on this call alone for that and must retry the
268
+ // removal with backoff, or isolate each run in its own child process.
269
+ // close() is still correct and worth calling regardless -- it prevents
270
+ // the silent second-handle-fork above, which is a real, distinct benefit.
271
+ if (this.busybase) {
272
+ try { this.busybase.close?.() } catch { /* best-effort */ }
273
+ this.busybase = null
274
+ globalThis.__thatcherBusyBase = null
275
+ _databaseInitialized = false
276
+ }
252
277
  }
253
278
 
254
279
  getConfigEngine() {