P
Prisma•4mo ago
Ortharion

Invalid error message when using transactions

We have a sync endpoint for our mobile app (it's offline capable first). The endpoint is entirely transaction based. So we iterate through the changes and build up an array of prisma queries and then wrap all those in a prismaClient.$transaction(transactions).
if (!isNil(changes.systems))
transactions = transactions.concat(this.handleSystemChanges(changes.systems, lastPulledAt));
if (!isNil(changes.equipment_photos))
transactions = transactions.concat(this.handleEquipmentPhotoChanges(changes.equipment_photos, lastPulledAt));

...

const result = await this.prismaClient.$transaction(transactions);
if (!isNil(changes.systems))
transactions = transactions.concat(this.handleSystemChanges(changes.systems, lastPulledAt));
if (!isNil(changes.equipment_photos))
transactions = transactions.concat(this.handleEquipmentPhotoChanges(changes.equipment_photos, lastPulledAt));

...

const result = await this.prismaClient.$transaction(transactions);
This is all wrapped in a try catch, but the issue is when something breaks, we seem to be getting erroneous error messages out of prisma. As in completely false error messages. It will say something like "can't find userId. Did you mean user?" Except the data being pushed to the user schema doesn't contain any invalid properties and userId is a valid property on the user schema. It's typically one of the other transactions that had an error. Any thoughts on why it's giving erroneous errors?
2 Replies
@Dex_davi
@Dex_davi•4mo ago
🤗
Ortharion
OrtharionOP•4mo ago
And this is kind of frustrating b/c obviously when this endpoint has issues, it's a big deal b/c our mobile app users are no longer able to push data to the database. So being able to quickly isolate the issue is important. bump
Want results from more Discord servers?
Add your server