You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5c6b770
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cache): stop quarantining a healthy database when the native module fails to load (#95)
A native-module load failure (ERR_DLOPEN_FAILED after a Node major
upgrade, ERR_UNKNOWN_BUILTIN_MODULE on runtimes without node:sqlite,
NODE_MODULE_VERSION mismatch) was caught by the CacheService
constructor's corruption handler, which renamed the user's healthy
cache.db to cache.db.corrupt-<timestamp> and recreated an empty
database. Reproduced with real data loss: a 1MB, 2646-entry cache that
passed integrity_check was quarantined when node_modules built for
Node 24 ran under Node 22.
- classify load failures in CacheService and rethrow without touching
the database or its -wal/-shm sidecars; genuine corruption still
gets the rename-aside recovery
- load the cache behind a warn-once latch (cli/cache-loader.ts): on
failure, warn once with an actionable hint and return undefined so
translate/write run cacheless with exit code 0
- make the optional cache in TranslationService/WriteService real:
no cache means cacheless, instead of falling back to
CacheService.getInstance(), which re-triggered the same crash
- deepl cache subcommands, which cannot run cacheless, now fail with
a ConfigError suggesting a reinstall or matching Node version
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17
17
18
18
### Fixed
19
19
20
+
-**cache**: A cache backend that fails to load (e.g. `better-sqlite3` ABI mismatch after a Node major upgrade, `ERR_DLOPEN_FAILED`) is no longer misclassified as database corruption. Previously the constructor's catch-all renamed the user's healthy `cache.db` to `cache.db.corrupt-<timestamp>` and recreated an empty database — verified to quarantine a 2,646-entry cache that passed `integrity_check`. Native-module load failures now leave the database and its `-wal`/`-shm` sidecars untouched; genuine corruption still triggers the rename-aside recovery. `deepl translate` and `deepl write` degrade to running without a cache (single warning per process, exit code 0) instead of crashing, since the cache backend is loaded lazily behind a warn-once latch; `deepl cache …` subcommands, which cannot run cacheless, fail with an actionable error suggesting a reinstall or matching Node version.
20
21
-**sync**: `deepl sync --frozen` now reports an accurate key count when drift is caused by a newly-added target locale. Previously the message read `Sync drift detected: 0 new, 0 stale keys.` because the frozen branch in `processBucket` short-circuited before promoting current-status keys missing a target-locale translation into `newKeys` — even though `--dry-run` against the same state correctly reported the backfill count. The drift exit code (10) is unchanged. The drift message now also surfaces `deletedKeys` and only mentions nonzero categories, mirroring the success-path summary format.
Copy file name to clipboardExpand all lines: docs/TROUBLESHOOTING.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -417,16 +417,20 @@ rm ~/.cache/deepl-cli/cache.db # or ~/.deepl-cli/cache.db for legacy installat
417
417
deepl cache enable
418
418
```
419
419
420
-
### "Cache database corrupted" with NODE_MODULE_VERSION mismatch
420
+
### "Translation cache backend failed to load" with NODE_MODULE_VERSION mismatch
421
421
422
422
**Cause:** The `better-sqlite3` native addon was compiled for a different Node.js version than the one currently running. This happens when you switch Node.js versions (e.g., via `nvm use`, `fnm`, or a system upgrade) without rebuilding native modules.
423
423
424
+
Translation and write commands keep working with caching disabled for the run; your cache database is not modified. `deepl cache` subcommands fail until the backend loads again.
425
+
424
426
**Solution:**
425
427
426
428
```bash
427
429
npm rebuild better-sqlite3
428
430
```
429
431
432
+
or reinstall the CLI / switch back to the Node.js version it was installed with.
0 commit comments