denoland/celldPublic

self-hosted, distributed Durable Objects

Bug: Nested transactionSync() calls fail through the root storage handle

DA

Calling storage.transactionSync() inside another storage.transactionSync() callback fails in celld, while the same pattern works in workerd. This can happen when an application starts a transaction and calls a helper or library that starts its own transaction through the same storage handle. ```JS const storage = this.ctx.storage;

storage.sql.exec("CREATE TABLE IF NOT EXISTS example (value INTEGER)");

storage.transactionSync(() => { storage.sql.exec("INSERT INTO example VALUES (1)");

storage.transactionSync(() => { storage.sql.exec("INSERT INTO example VALUES (2)"); }); }); ``` Expected behavior is for both inserts to succeed within the outer transaction. Nested calls should preserve workerd鈥檚 rollback behavior too. Catching an inner transaction鈥檚 error should roll back only its writes, while an outer rollback should undo both levels.

Instead, celld throws: ``` storage.transaction: cannot start a transaction within a transaction ```

The synchronous transaction path creates a transaction view for the callback but does not track it as the active synchronous transaction. A nested call through the original storage handle therefore attempts another top-level transaction instead of a savepoint. The implementation is in [DurableObjectStorage.transactionSync()](https://github.com/denoland/celld/blob/v0.5.1/crates/celld/js/harness.js#L1744).

Could celld track the active synchronous transaction so nested calls through the root storage handle match workerd?

  1. CO

    +1 this blocks running the [cloudflare agents sdk](https://github.com/cloudflare/agents) which performs nested transactions

  2. bartlomiejuassigned bartlomiejulast month on GitHub

  3. BA

    Thanks for the report. This is now fixed and will be released in the next version.

  4. bartlomiejuclosedlast month on GitHub

  5. bartlomiejureferenced 81d1c52fb5belast month on GitHub

  6. bartlomiejureferenced 0aa22f091625last month on GitHub

  7. bartlomiejureferenced 46692d514ac3last month on GitHub

  8. ryreferenced def3ad02192dlast month on GitHub

  9. bartlomiejureferenced bab562b22376last month on GitHub

  10. bartlomiejureferenced af69bb4337c5last month on GitHub

  11. bartlomiejureferenced bad4649d01f0last month on GitHub