`await tx.isPersisted.promise` is not working
I've been using tanstack/db for about a month now, and the
await tx.isPersisted.promise has stopped working at some point.
I don't remember which version, but I'm currently on 0.1.27 and it doesn't work.
13 Replies
unwilling-turquoiseOP•2mo ago
The promise just hangs and eventually it fails. Even though the change is applied and the server API is successful.
unwilling-turquoiseOP•2mo ago

unwilling-turquoiseOP•2mo ago
And this is the error:

unwilling-turquoiseOP•2mo ago
I'm running the delete operation in a transaction on the server and getting the txid with
SELECT pg_current_xact_id()::xid::text as txid inside an actual transaction.
Any idea on what I could be doing wrong here?
I also tried updating electric to 1.1.14, but that doesn't seem to help either 🤔foreign-sapphire•2mo ago
Can you try running localStorage.debug = '*' in your browser console?
That'll give you some debugging output
Odds are your txid isn't matching right
unwilling-turquoiseOP•2mo ago
I wonder why that would happen?

unwilling-turquoiseOP•2mo ago
LMAO, I think I figured it out
I'm using drizzle. When writing a transaction with drizzle you have to use the transaction that you get from the callback (usually named
tx), but I was using the main db instance in the transaction and that's why they didn't match up.foreign-sapphire•2mo ago
Haha I've done that before 😀
unwilling-turquoiseOP•2mo ago
Thanks for the pointer.
I was going crazy 😄
foreign-sapphire•2mo ago
Yeah, I need to add this to the docs
national-gold•2mo ago
can you clarify what you should use instead of the main
db instance? I think something similar is happening to me but I'm not sure how to fix itunwilling-turquoiseOP•2mo ago
You should use the transaction that is passed in as the first argument of
db.transaction like this:
Here to update the data I used tx.insert instead of db.insert.national-gold•2mo ago
gotcha, thanks!