Skip to content

v3.13.1 β€” #2432 sql.js MEMFS leak + #2431 graph-edge dual-write corruption

Choose a tag to compare

@ruvnet ruvnet released this 22 Jun 15:51
43b5958

πŸ”§ Bug-fix release

#2432 β€” Unbounded sql.js MEMFS leak (HIGH, ~36 GB observed)

`ControllerRegistry.initController()` was calling `controllers.set(name, ...)` without closing the prior instance. `SqlJsRvfBackend` wrappers held an Emscripten MEMFS file (~11 MB each = sizeof `memory.db`) that only releases on explicit `.close()` β€” JS GC of the wrapper does NOT reclaim MEMFS because the sql.js module is a process singleton.

Fix: added `closePriorIfAny(name)` helper, called before every `controllers.set()` site. Best-effort close (catches errors so replacement always proceeds).

#2431 β€” graph-edge-writer dual-write corrupts memory.db (HIGH, ADR-130 regression)

`graph-edge-writer.ts` opened sql.js, did in-memory writes, then called `fs.writeFileSync(dbPath, db.export())` after every edge insert. The whole-file flush overwrote `memory.db` while the better-sqlite3 bridge was actively writing through its WAL β€” the exact dual-write race ADR-068 (#1257) removed.

Symptom: `PRAGMA integrity_check` returns `database disk image is malformed (11)` after one `memory_store` + `causal-edge` sequence.

Fix: ported from sql.js to better-sqlite3 + WAL mode. Same native engine as the bridge β†’ no whole-file fsync β†’ no race. Public API unchanged. Smoke-tested: 50 concurrent `insertGraphEdge()` calls + `PRAGMA integrity_check` β†’ `ok`.

Note: this is the minimum-safe fix. The architecturally cleaner fix (route edge writes through the bridge's controller layer per ADR-068) is deferred to a future ADR.

Distribution

Package latest alpha v3alpha
`@claude-flow/memory` 3.0.0-alpha.21 3.0.0-alpha.21 3.0.0-alpha.21
`@claude-flow/cli` 3.13.1 3.13.1 3.13.1
`claude-flow` 3.13.1 3.13.1 3.13.1
`ruflo` 3.13.1 3.13.1 3.13.1

Upgrade

```bash
npx ruflo@latest # picks up 3.13.1
npx claude-flow@latest # picks up 3.13.1
```

Cross-references

  • πŸ”— PR #2444 (this release)
  • πŸ”— Issue #2432 (MEMFS leak, closed)
  • πŸ”— Issue #2431 (dual-write corruption, closed)
  • πŸ”— Companion #2443 (v3.13.0 doctor fix, merged)
  • πŸ”— Related ADR-068 / ADR-130 (architectural context)

πŸ€– Generated with RuFlo