i managed to get a workaround but its ugly. private _exec(sql: string, params?: any[]): void { if (params && params.length > 0) { this.ctx.storage.sql.exec(sql, ...params); } else { this.ctx.storage.sql.exec(sql); } } protected exec(sql: string, params?: any[]): void; protected exec(query: SQLiteInsertBase, 'sync', any, any, false, never>): void; protected exec(input: string | SQLiteInsertBase, 'sync', any, any, false, never>, params?: any[]): void { if (typeof input === 'string') { this._exec(input, params); } else { const sql = input.toSQL(); this._exec(sql.sql, sql.params); } } await this.ctx.storage.transactionSync>(async () => { this.logger.debug(`Inserting download record for transfer: ${this.transferId}`); // Insert data using transaction - if any of these fail, entire transaction rolls back this.exec(this.db.insert(schema.downloadsTable).values({ id: this.transferId, userId: transferData.userId, fileSize: transferData.fileSize, fileName: transferData.fileName, contentType: transferData.contentType, status: TransferStatus.READY, downloadCount: 0, createdAt: new Date().toISOString(), expiresAt: expiresAt })); this.logger.debug(`Inserting transfer details for transfer: ${this.transferId}`); // Insert transfer details this.exec(this.db.insert(schema.transferDetailsTable).values({ transferId: this.transferId, ...transferData.transferDetails, passwordHash: passwordHash })); // Insert parts from transfer data using bulk insert if (transferData.parts && transferData.parts.length > 0) { this.logger.debug(`Inserting ${transferData.parts.length} parts for transfer: ${this.transferId}`); this.exec(this.db.insert(schema.transferPartsTable).values( transferData.parts.map(part => ({ id: part.id, transferId: this.transferId, size: part.size, start: part.start, end: part.end, sha1: part.sha1 || null, storage: part.storage })) )); this.logger.debug(`Successfully inserted all parts for transfer: ${this.transferId}`); } }); // If we get here, transaction was successful and committed this.logger.info(`Transaction committed successfully for transfer: ${this.transferId}`); this.logger.debug(`Setting expiration alarm for transfer: ${this.transferId}`); // Set alarm for expiration after transaction completes await this.state.storage.setAlarm(new Date(expiresAt)); this.logger.info(`Alarm set successfully for transfer: ${this.transferId}`); }