Skip to content

Firebase dataconnect transaction (emulator) #8658

Closed
@federicobaiocco

Description

@federicobaiocco

[REQUIRED] Environment info

14.4.0

firebase-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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions