From 7dfec58bcc03b9213a8b0b3170a72cc5947616ee Mon Sep 17 00:00:00 2001 From: Florian Blondet Date: Mon, 11 May 2026 11:34:07 +0200 Subject: [PATCH] Fix async sync error conversion --- integration-tests/tests/async.test.js | 11 +++++++++++ promise.js | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/integration-tests/tests/async.test.js b/integration-tests/tests/async.test.js index 38f24d2..aee4f4d 100644 --- a/integration-tests/tests/async.test.js +++ b/integration-tests/tests/async.test.js @@ -340,6 +340,17 @@ test.serial("Database.exec() after close()", async (t) => { }); }); +test.serial("Database.sync() after close()", async (t) => { + const db = t.context.db; + db.close(); + await t.throwsAsync(async () => { + await db.sync(); + }, { + instanceOf: TypeError, + message: "The database connection is not open" + }); +}); + 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;"); diff --git a/promise.js b/promise.js index f020de7..f692b0f 100644 --- a/promise.js +++ b/promise.js @@ -101,9 +101,9 @@ class Database { }); } - sync() { + async sync() { try { - return this.db.sync(); + return await this.db.sync(); } catch (err) { throw convertError(err); }