You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
transaction.get(ref) followed by transaction.set(ref, {...}) is causing the transaction to fail with error 'Document already exists' if the document was created by another app between the get and set.
Expected behavior is for the transaction to fail the first attempt because the document changed (was created) between the read and write. But it's also expected that the transaction will automatically retry.
I see the expected behavior in v9.6.11, and the error in v9.10.0. There appears to be a regression somewhere in between these versions.
Steps to reproduce:
Before repro, execute clean() to delete the document.
Execute method transact().
During the sleep in transact(), execute method write(). This might be done by a second browser.
Observe that the transaction from step 2 fails without retry. But the transaction retries and is successful in 9.6.11.
Relevant Code:
asyncfunctionsleep(ms){returnnewPromise((resolve)=>{setTimeout(resolve,ms);});}asyncfunctionclean(){console.log("starting clean")awaitdeleteDoc(ref);console.log("finished clean")}asyncfunctionwrite(){awaitsetDoc(ref,{created: (newDate()).toUTCString()})console.log("Doc created")}asyncfunctiontransact(){awaitrunTransaction(db,async(tx)=>{constsnapshot=awaittx.get(ref);console.log("doc read")if(snapshot.exists()){console.log("document exists - updating last write")tx.update(ref,{lastWrite: (newDate()).toUTCString()})return;}console.log("sleeping")awaitsleep(10000);console.log("wake from sleep")tx.set(ref,{created: (newDate()).toUTCString()});});console.log("Transaction successful");}asyncfunctionreproduce(){awaitclean();setTimeout(write,2000);transact();}reproduce();
The text was updated successfully, but these errors were encountered:
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
transaction.get(ref)
followed bytransaction.set(ref, {...})
is causing the transaction to fail with error 'Document already exists' if the document was created by another app between the get and set.Expected behavior is for the transaction to fail the first attempt because the document changed (was created) between the read and write. But it's also expected that the transaction will automatically retry.
I see the expected behavior in v9.6.11, and the error in v9.10.0. There appears to be a regression somewhere in between these versions.
Steps to reproduce:
clean()
to delete the document.transact()
.transact()
, execute methodwrite()
. This might be done by a second browser.Relevant Code:
The text was updated successfully, but these errors were encountered: