Repository navigation
Closed
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.topic: $transactionRelated to .$transaction(...) Client APItopic: loggingtopic: prisma-clienttopic: transaction
Description
Bug description
When logging the transactionConnection in an interactive transaction to the console, Node hangs for a long time and then crashes with an ERR_INTERNAL_ASSERTION error:
at new NodeError (node:internal/errors:399:5)
at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1550:10)
at formatRaw (node:internal/util/inspect:1063:12)
at formatValue (node:internal/util/inspect:841:10)
at inspect (node:internal/util/inspect:365:10)
at i.<computed> (/xxx/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:163:12995)
at formatValue (node:internal/util/inspect:806:19)
at formatProperty (node:internal/util/inspect:1920:11)
at formatRaw (node:internal/util/inspect:1055:9)
at formatValue (node:internal/util/inspect:841:10)
at formatProperty (node:internal/util/inspect:1920:11)
at formatRaw (node:internal/util/inspect:1055:9)
at formatValue (node:internal/util/inspect:841:10)
at inspect (node:internal/util/inspect:365:10)
at i.<computed> (/xxx/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:163:12995)
at formatValue (node:internal/util/inspect:806:19)
at formatProperty (node:internal/util/inspect:1920:11)
at formatRaw (node:internal/util/inspect:1055:9)
at formatValue (node:internal/util/inspect:841:10)
at formatProperty (node:internal/util/inspect:1920:11)
at formatRaw (node:internal/util/inspect:1055:9)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at new NodeError (node:internal/errors:399:5)
at Function.fail (node:internal/assert:20:9)
at handleMaxCallStackSize (node:internal/util/inspect:1550:10)
at formatRaw (node:internal/util/inspect:1063:12)
at formatValue (node:internal/util/inspect:841:10)
at inspect (node:internal/util/inspect:365:10)
at i.<computed> (/xxx/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:163:12995)
at formatValue (node:internal/util/inspect:806:19)
at inspect (node:internal/util/inspect:365:10)
at formatWithOptionsInternal (node:internal/util/inspect:2273:40)
at formatWithOptions (node:internal/util/inspect:2135:10)
at console.value (node:internal/console/constructor:340:14)
at console.log (node:internal/console/constructor:377:61)
at /xxx/apiApp.js:44:13
at Proxy._transactionWithCallback (/xxx/node_modules/.pnpm/@[email protected][email protected]/node_modules/@prisma/client/runtime/library.js:179:9419) {
code: 'ERR_INTERNAL_ASSERTION'
}
The above error seems to be printed numerous times (my terminal output truncates it). So this is just one iteration.
How to reproduce
reproduction.js
const prisma = new PrismaClient({
datasources: {
db: {
url: getConnectionUrl(),
},
},
})
prisma
.$transaction((connection) => {
console.log('1');
console.log(connection);
console.log('2');
})
.then(() => console.log('finished'));
Above, '1' will print, but no other console.log statements will fire
Expected behavior
No response
Prisma information
Environment & setup
- OS: macOS
- Database: PostgreSQL
- Node.js version: v18.16.0
Prisma Version
4.13.0
Reacted by Oleksandr Dykyi
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.topic: $transactionRelated to .$transaction(...) Client APItopic: loggingtopic: prisma-clienttopic: transaction
Activity
[-]Console.log(transactionConnection) crashes Node with ERR_INTERNAL_ASSERTION[/-][+]Inside `prisma.$transaction`: console.log(connection) crashes Node with `ERR_INTERNAL_ASSERTION`[/+][-]Inside `prisma.$transaction`: console.log(connection) crashes Node with `ERR_INTERNAL_ASSERTION`[/-][+]Inside `prisma.$transaction`: `console.log(connection)` crashes Node with `ERR_INTERNAL_ASSERTION`[/+]janpio commentedon May 17, 2023
That should not happen. Still I have to ask: Why do you want to log the transaction scoped Prisma Client, in your example called
connection, in our docs usually calledtx?(I think we recently had an issue about logging the normal Prisma Client object - this is probably related)
(Update: Found it: #18292)
marnixhoh commentedon May 18, 2023
That's a good question haha!
I ran into this issue when I was writing a test (in Jest) which tested whether or not a particular function got called with the right arguments. Here the first argument of myFunction is the
connection. That's why I'm expecting that the first argument isany(Object):In some cases, this caused my test suite to freeze and sometimes it would throw weird errors.
So while debugging this I console.logged
connectionto check its value and then I realized that this was the culprit.PS I worked around it in my test suites by removing the
connectionargument from the function call before comparing:I hope this helps
jkomyno commentedon Oct 1, 2024
Hi @marnixhoh, it's been a while, but I attempted to reproduce this and here's what I got:
On Prisma 4.13.0, I experience ~30 seconds of delay between
1and2are logged, as the stringifiedconnectionobject is very large to print. The query then terminates with aPrismaClientKnownRequestError:This issue is fixed as of 5.11.0
The only thing remaining to allow us to close this issue, is to create a regression test, so that it doesn't happen again.
marnixhoh commentedon Oct 1, 2024
@jkomyno It has been a while indeed! Nonetheless, I really appreciate your reply. 😊
Thank you for looking into this and fixing it.
I will keep this issue open then, so that you can close it whenever the regression test has been implemented
test(client): regression test for #19137
test(client): regression test for #19137 (#25336)