{"record":{"id":"f856c3eae2164ea7","repo":"tursodatabase/turso","slug":"transactionasync-is-not-supported-with-remotewrite-f856c3","errorCode":null,"errorMessage":"transactionAsync is not supported with remoteWritesExperimental yet; use the deprecated transaction() for now","messagePattern":"transactionAsync is not supported with remoteWritesExperimental yet; use the deprecated transaction\\(\\) for now","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/javascript/sync/packages/wasm/promise-vite-dev-hack.ts","lineNumber":333,"sourceCode":"        Object.defineProperties(properties.immediate.value, properties);\n        Object.defineProperties(properties.exclusive.value, properties);\n        return properties.default.value as TransactionFunction<F>;\n    }\n\n    /**\n     * Returns a function that executes the given function in a transaction\n     * on a connection owned for the whole BEGIN..COMMIT window; the callback\n     * receives a {@link Transaction} handle as its first argument.\n     *\n     * Not supported together with {@link DatabaseOpts.remoteWritesExperimental}\n     * yet: remote-writes transactions run on the remote server and have no\n     * local connection to hand out.\n     */\n    override transactionAsync<F extends (txn: Transaction, ...args: any[]) => Promise<any>>(\n        fn: F,\n    ): AsyncTransactionFunction<F> {\n        if (this.#remoteWriter) {\n            throw new Error(\n                \"transactionAsync is not supported with remoteWritesExperimental yet; use the deprecated transaction() for now\",\n            );\n        }\n        return super.transactionAsync(fn);\n    }\n\n    /**\n     * close the database and relevant files\n     */\n    async close() {\n        if (this.#remoteWriter) {\n            await this.#remoteWriter.close();\n        }\n        if (this.#engine != null) {\n            if (this.name != null && this.#worker != null) {\n                await Promise.all([\n                    unregisterFileAtWorker(this.#worker, this.name),\n                    unregisterFileAtWorker(this.#worker, `${this.name}-wal`),","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/sync/packages/wasm/promise-vite-dev-hack.ts#L315-L351","documentation":"The vite promise wrapper overrides transactionAsync() with the same restriction as the turbopack build: when the database runs with remoteWritesExperimental, transactions execute on the remote server and no local connection exists to pass as a Transaction handle, so the override throws as soon as #remoteWriter is set. The doc comment points users at the deprecated transaction() whose override understands remote writes.","triggerScenarios":"`new Database(path, { url, authToken, remoteWritesExperimental: true })` followed by `db.transactionAsync(async (txn) => { ... })`; shared app code that picks transactionAsync for its nicer ergonomics running against a remote-writes-enabled database.","commonSituations":"Adopting remote writes in an existing vite dev-server app that used transactionAsync; monorepos where one codebase serves both local-sync and remote-writes deployments; following newer transactionAsync documentation while the database opts enable remoteWritesExperimental.","solutions":["Use `db.transaction(fn)` — in remote-writes mode its override wraps the callback in remote BEGIN..COMMIT correctly","Gate the choice on the database options: transactionAsync only when remoteWritesExperimental is falsy","If the Transaction handle is required, disable remoteWritesExperimental and use local writes with push()"],"exampleFix":"// before\nconst db = new Database(\"app.db\", { url, authToken, remoteWritesExperimental: true });\nconst tx = db.transactionAsync(async (txn) => { /* ... */ }); // throws\n\n// after\nconst db = new Database(\"app.db\", { url, authToken, remoteWritesExperimental: true });\nconst tx = db.transaction(async () => { /* ... */ }); // remote BEGIN..COMMIT","handlingStrategy":"validation","validationCode":"// Choose the transaction API from the config you own\nconst remoteWrites = !!opts.remoteWritesExperimental;\nconst db = new Database(path, opts);\n\nconst tx = remoteWrites\n  ? db.transaction(fn)        // remote BEGIN..COMMIT\n  : db.transactionAsync(fn); // local Transaction handle","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize transaction creation in one helper shared by the app","Document at the helper boundary why remote writes exclude transactionAsync","Re-evaluate when the library adds transactionAsync support for remote writes"],"tags":["transaction","remote-writes","wasm","vite","sync"],"backgroundTag":"unsupported-feature-combination","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}