From 1ed77870f96ea2896befd050d74898f5d96eb56d Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 26 Nov 2026 14:03:46 +0100 Subject: [PATCH] test(db): see the unnamed temp files SQLite 3.54 opens on Linux SQLite 3.54, which better-sqlite3 13.2.0 bundles, opens its temp files with O_TMPFILE where the system has it. On Linux such a file has no name: among the process's descriptors it reads /# (deleted) instead of etilqs_. The watcher only looked for the name, so the control test saw nothing, and the test that TREK's own connection never touches a temp file would have passed whatever happened. The watcher now knows both forms; the control proves again that it sees them. --- server/tests/unit/db/connection.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/tests/unit/db/connection.test.ts b/server/tests/unit/db/connection.test.ts index a94838591..00a279a7b 100644 --- a/server/tests/unit/db/connection.test.ts +++ b/server/tests/unit/db/connection.test.ts @@ -87,8 +87,10 @@ describe('openDatabase', () => { }); }); -// SQLite names every temp file etilqs_. Linux unlinks the file the -// moment it is opened, so it only shows among the process's open descriptors; +// SQLite names every temp file etilqs_, except where it can open it +// without a name: from 3.54 on Linux uses O_TMPFILE, and such a file shows among +// the process's open descriptors as /# (deleted). Before that, Linux +// unlinked the named file the moment it was opened, so it showed only there too. // Windows keeps it in the temp directory until it is closed. macOS offers // neither view, which is why the test below does not run there. const canSeeTempFiles = process.platform === 'linux' || process.platform === 'win32'; @@ -104,7 +106,7 @@ function sqliteTempFiles(): string[] { return []; } }) - .filter((target) => target.includes('etilqs_')); + .filter((target) => target.includes('etilqs_') || /\/#\d+ \(deleted\)$/.test(target)); } return fs.readdirSync(os.tmpdir()).filter((name) => name.startsWith('etilqs_')); }