Closed
Description
Operating System
mac
Environment (if applicable)
vscode
Firebase SDK Version
last
Firebase SDK Product(s)
DataConnect
Project Tooling
hi
I do not understand why this error :
Errors: input: cannot commit transaction: pq: unexpected transaction status idle
The database is updated after the mutation but in the code, it throws an error, and in the console also.
I have not tried in production, i am working just in localhost, and I do not understand if this transaction is working or not. It is not acceptable to hack the code with this logging an error, but doing the update in the db
the mutation:
mutation InsertProductOxelaWithImage(
$handle: String!
$title: String!
$description: String
$availableForSale: Boolean!
$productType: String
$imageUrl: String!
$imageAltText: String
$imageWidth: Int!
$imageHeight: Int!
$featured: Boolean!
$displayPosition: Int!
) @auth(level: PUBLIC) @transaction {
# Étape 0 : s'assurer que le handle n'existe pas déjà
query
@check(
expr: "response.query.products.size() == 0"
message: "A product with this handle already exists"
)
@redact {
products(where: { handle: { eq: $handle } }) {
id
}
}
# Étape 1 : création du produit
product: product_insert(
data: {
handle: $handle
title: $title
description: $description
productType: $productType
availableForSale: $availableForSale
}
) @check(expr: "this != null", message: "Product creation failed")
# Étape 2 : création de l'image
productImage_insert(
data: {
productId_expr: "response.product.id"
url: $imageUrl
altText: $imageAltText
width: $imageWidth
height: $imageHeight
featured: $featured
displayPosition: $displayPosition
}
) @check(expr: "this != null", message: "Image creation failed")
# # Étape 3 : mise à jour du produit avec l'image en vedette
product_update(
key: { id_expr: "response.product.id" }
data: { featuredImageId_expr: "response.productImage_insert.id" }
) @check(expr: "this != null", message: "Failed to link featured image")
}
the schema
type SEO @table {
id: UUID! @default(expr: "uuidV4()")
title: String!
description: String!
keywords: String!
}
type ProductImage @table {
id: UUID! @default(expr: "uuidV4()")
product: Product! @unique
url: String! @col(name: "url", dataType: "text")
altText: String @col(name: "alt_text", dataType: "text")
width: Int! @col(name: "width", dataType: "int")
height: Int! @col(name: "height", dataType: "int")
featured: Boolean! @col(name: "featured", dataType: "boolean")
displayPosition: Int! @col(name: "display_position", dataType: "int")
}
# Product
type Product @table {
id: UUID! @default(expr: "uuidV4()")
featuredImage: ProductImage
seo: SEO
handle: String! @col(name: "handle", dataType: "varchar(100)") @unique
title: String! @col(name: "title", dataType: "varchar(100)")
description: String @col(name: "description", dataType: "text")
# price ? NOPE
productType: String @col(name: "product_type", dataType: "varchar(100)")
availableForSale: Boolean!
@col(name: "available_for_sale", dataType: "boolean")
createdAt: Date! @default(expr: "request.time")
updatedAt: Date! @default(expr: "request.time")
}
the log error:
sources: connector/mutations.gql [1531B] connector/queries.gql [1014B]
I0604 19:19:48.323570 38070 deny_unless_true.go:40] authentication error (@check): granted with true result: true
I0604 19:19:48.324817 38070 every.go:44] @check granted after running 1 checks
I0604 19:19:48.334316 38070 deny_unless_true.go:40] authentication error (@check): granted with true result: true
I0604 19:19:48.334347 38070 every.go:44] @check granted after running 1 checks
I0604 19:19:48.339578 38070 deny_unless_true.go:40] authentication error (@check): granted with true result: true
I0604 19:19:48.339599 38070 every.go:44] @check granted after running 1 checks
I0604 19:19:48.346476 38070 deny_unless_true.go:40] authentication error (@check): granted with true result: true
I0604 19:19:48.346525 38070 every.go:44] @check granted after running 1 checks
I0604 19:19:48.346908 38070 executor.go:97] [operation "InsertProductOxelaWithImage" attempt 1] DBStats beforeRun: sql.DBStats{MaxOpenConnections:1, OpenConnections:0, InUse:0, Idle:0, 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}
W0604 19:19:48.347710 38070 engine.go:174] [/emulator/p6--oxela--firebase-root-service e644] ExecuteMutation InsertProductOxelaWithImage: failed. Connector: default
Auth: public
Variables:
{
"availableForSale": true,
"description": "lpopopopop",
"displayPosition": 1,
"featured": false,
"handle": "admin/admin/",
"imageAltText": "z-unclassified",
"imageHeight": 90,
"imageUrl": "/assets/fallback-image-product.jpg",
"imageWidth": 96,
"productType": "z-unclassified",
"title": "admin/admin/"
}
Errors: input: cannot commit transaction: pq: unexpected transaction status idle
Data:
{
"product": {
"id": "aa1a8102588544278817d646ef68206a"
},
"productImage_insert": {
"id": "538e160ad94f4830950815c4ed9dac94"
},
"product_update": {
"id": "aa1a8102588544278817d646ef68206a"
}
}
### Detailed Problem Description
at home
### Steps and code to reproduce issue
launch the request, with some rando variables in the mutation