From ac9bf8e5941a71dcb9b9399cdfe43dc95a791e05 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 31 Jan 2026 01:42:10 +0000 Subject: [PATCH] fix(db): add transaction method to Node SQLite polyfill The NodeDatabasePolyfill class was missing the transaction() method that Bun's SQLite provides. This caused 'e.transaction is not a function' errors when running via npx/Node.js (e.g., during 'sentry auth status' credential verification which calls setOrgRegions()). Add transaction() method that wraps functions in BEGIN/COMMIT with ROLLBACK on error, matching Bun's db.transaction() API. --- script/node-polyfills.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/script/node-polyfills.ts b/script/node-polyfills.ts index 9410750927..fa23063637 100644 --- a/script/node-polyfills.ts +++ b/script/node-polyfills.ts @@ -56,6 +56,25 @@ class NodeDatabasePolyfill { close(): void { this.db.close(); } + + /** + * Wraps a function in a transaction. Returns a callable that executes + * the function within BEGIN/COMMIT, with ROLLBACK on error. + * Matches Bun's db.transaction() API. + */ + transaction(fn: () => T): () => T { + return () => { + this.db.exec("BEGIN"); + try { + const result = fn(); + this.db.exec("COMMIT"); + return result; + } catch (error) { + this.db.exec("ROLLBACK"); + throw error; + } + }; + } } const bunSqlitePolyfill = { Database: NodeDatabasePolyfill };