Skip to content

Writing to Firestore directly in the middle of a transaction updateFunction causes a deadlock/hang #2481

@mmmulani

Description

@mmmulani

I ran into this code mistake I made recently, and I think it would be nice if the API could help catch this issue.

Steps to reproduce:

Try writing to a document directly while in a transaction.

await db.runTransaction(async t => {
  const docRef = db.collection('cities').doc('Toronto');
  await docRef.set(...);
});

While of course, this is a code issue caused by the programmer, it is particularly frustrating to debug as it seems to cause a deadlock/unfulfilled promise. Possibly the API could help catch this issue by marking the stack and throwing an error (maybe only in dev?).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions