drizzle-team / drizzle-team/drizzle-orm

[BUG]: transaction not waiting for result in SQLite Durable Objects

Open
#4,322 0 comments 4 reactions 0 assignees View on GitHub
bug db/sqlite driver/durable-objects priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

0.41.0

### What version of `drizzle-kit` are you using?

0.30.5

### Other packages

_No response_

### Describe the Bug

Using SQLite Durable Objects drizzle client transactions don't wait for the operations inside to be executed.

For example the code bellow, the last console log is executed right after db.transaction execution call. It should wait for the update operation to end.

There is this ticket #4202 I think it's complaining about the same issue and is providing a solution that I think it would work.

```ts
console.log("1) CODE BEFORE TRANSACTION")
await db.transaction(async (tnx) => {
console.log("2) START TRANSACTION")
await tnx.update(dbSchema.subscriptions)
.set({ name: 'Carlos' })
.where(eq(dbSchema.subscriptions.id, 3))
console.log("3) END TRANSACTION")
});

console.log("4) CODE AFTER TRANSACTION")
```

Output:

```
1) CODE BEFORE TRANSACTION
2) START TRANSACTION
4) CODE AFTER TRANSACTION
3) END TRANSACTION`
```

Expected Output:

```
1) CODE BEFORE TRANSACTION
2) START TRANSACTION
3) END TRANSACTION
4) CODE AFTER TRANSACTION
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.