Repository navigation
Description
[REQUIRED] Environment info
14.4.0firebase-tools: 14.4.0
Platform: macOS
[REQUIRED] Test case
Trying to run a transaction with multiple deletes/inserts fails with errror message: cannot commit transaction: pq: unexpected transaction status idle (when running on dataconnect emulator)
[REQUIRED] Steps to reproduce
Create a mutation:
mutation Example($id: String) @auth(level: NO_ACCESS) @transaction {
productTag_deleteMany(where: { productId: { eq: $id }})
product_upsert(data: {
id: $id
name: "Dummy Product"
type: "DIGITAL"
active: true
createdAt: "2025-05-27T10:00:00Z"
updatedAt: "2025-05-27T10:00:00Z"
language: "en"
publicationDate: "2025-06-01"
metadataStatus: "Draft"
})
productCategory_insertMany(data: [
{ productId: $id, categoryCode: "ABC123" }
])
}
It works without the @transaction
[REQUIRED] Expected behavior
Run all the deletes/inserts within a transaction
[REQUIRED] Actual behavior
Fails with error message: cannot commit transaction: pq: unexpected transaction status idle
I0527 07:16:09.343656 76082 prepare.go:118] [operation "Test" attempt 1] preparePlan succeeded
I0527 07:16:09.343690 76082 prepare.go:109] [operation "Test" attempt 1] DBStats beforePrepare: sql.DBStats{MaxOpenConnections:1, OpenConnections:1, InUse:0, Idle:1, WaitCount:0, WaitDuration:0, MaxIdleClosed:0, MaxIdleTimeClosed:0, MaxLifetimeClosed:0}, afterPrepare: sql.DBStats{MaxOpenConnections:1, OpenConnections:1, InUse:0, Idle:1, WaitCount:0, WaitDuration:0, MaxIdleClosed:0, MaxIdleTimeClosed:0, MaxLifetimeClosed:0}
I0527 07:16:09.354744 76082 executor.go:97] [operation "Test" attempt 1] DBStats beforeRun: sql.DBStats{MaxOpenConnections:1, OpenConnections:1, InUse:0, Idle:1, WaitCount:0, WaitDuration:0, MaxIdleClosed:0, MaxIdleTimeClosed:0, MaxLifetimeClosed:0}, afterRun: sql.DBStats{MaxOpenConnections:1, OpenConnections:0, InUse:0, Idle:0, WaitCount:0, WaitDuration:0, MaxIdleClosed:0, MaxIdleTimeClosed:0, MaxLifetimeClosed:0}
W0527 07:16:09.355025 76082 engine.go:174] [/emulator/distribution-platform-service-dev afa1] ExecuteGraphql Test: failed.
Auth: admin
Variables:
{
"id": "c4645212-0c2d-41bb-b867-9f83e442cbb1"
}
Errors: input: cannot commit transaction: pq: unexpected transaction status idle
Activity
federicobaiocco commentedon May 27, 2025
Update: Running the exact same mutation on firebase console works. It only fails when running on emulator
[-]Firebase dataconnect transaction[/-][+]Firebase dataconnect transaction (emulator)[/+]Cruzor-Blade commentedon May 27, 2025
I am witnessing exactly the same errors. I was trying to delete many elements, after filtering.
And even
upserttransactions fail too.I am on firebase tools
14.4.0and node22.Edit: Seems that all mutations are not working.
For my particular case, I am running the mutations under
firebase-admin.Getting the error
even though I am impersonating a validated token with
impersonate: {authClaims: {sub: uid}}under the privileged environmentaalej commentedon May 29, 2025
Thanks for raising this and for filing a detailed report @federicobaiocco! I was able to reproduce the error when using
@transaction. As you mentioned, when using the emulators, the same mutation without@transactionworks. Also verified that the same mutation(with@transaction) works on production. So this seems like a bug on the emulator.Just to note, even though an error was raised, it seems like the transaction still went through since product tag deletion, product upsert, and product category insert were successful.
Let me check this with our engineering team. Sharing the mcve here.
joehan commentedon May 29, 2025
@Cruzor-Blade I think you are facing a different problem - could you open a separate issue for that (with an MCVE if possible)?
mr13tech commentedon Jun 3, 2025
I also having this problem today - was setting up new machine and everything is red after latest
firebase-toolsinstall. Had to remove@transactionadnotations from seed mutations.joehan commentedon Jun 24, 2025
This issue is fixed as of 14.8.0. Sorry for the inconvenience all!
federicobaiocco commentedon Jun 24, 2025
Excellent thanks!