From 28636c4c7aa1d56eefea2dc40a81afacd3baa942 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Tue, 17 Mar 2026 19:44:27 +0200 Subject: [PATCH] Fix async interrupt tests timing out on Windows Add a short delay before calling interrupt() in the Database.interrupt() and Statement.interrupt() tests to ensure the query is actively running on the tokio runtime. Without the delay, the interrupt flag can be set before sqlite3_step() starts, causing a race condition where the flag gets consumed without effect on Windows. --- integration-tests/tests/async.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/integration-tests/tests/async.test.js b/integration-tests/tests/async.test.js index faa2538..096fde8 100644 --- a/integration-tests/tests/async.test.js +++ b/integration-tests/tests/async.test.js @@ -344,6 +344,10 @@ test.serial("Database.interrupt()", async (t) => { const db = t.context.db; const stmt = await db.prepare("WITH RECURSIVE infinite_loop(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM infinite_loop) SELECT * FROM infinite_loop;"); const fut = stmt.all(); + // Wait for the query to start executing on the tokio runtime before + // interrupting, otherwise the interrupt flag may be set before the first + // sqlite3_step() and get consumed without effect on some platforms. + await new Promise(resolve => setTimeout(resolve, 100)); db.interrupt(); await t.throwsAsync(async () => { await fut; @@ -359,6 +363,7 @@ test.serial("Statement.interrupt()", async (t) => { const db = t.context.db; const stmt = await db.prepare("WITH RECURSIVE infinite_loop(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM infinite_loop) SELECT * FROM infinite_loop;"); const fut = stmt.all(); + await new Promise(resolve => setTimeout(resolve, 100)); stmt.interrupt(); await t.throwsAsync(async () => { await fut;