Cannot read properties of undefined
Environment
Database: MySQL OS: Windows Node.js v20.12.1
Bug
TypeError: Cannot read properties of undefined
When an application loses its connection to the database, the application crashes with the error TypeError: Cannot read properties of undefined (reading '__knexUid')
#Fix \knex\lib\client.js:344:58 connection.__knexUid to connection?.__knexUid
Please provide reproductive repo
Just got the same in our production env.
Please provide reproductive repo
That's impossible from my end; ours happens under extremely high loads before it crashes and it's a database with 500GB of RAM. Yes, RAM.
I can't replicate that kind of load even if I tried.
We also see this, both in production and test environments. And it's not just Windows.
Challenging to replicate though.
Running into this.
Here's some more info on my use case.
It's a busy postgres database. I suspect I'm getting timeouts or even disconnects because the server is short on resources.
We are streaming results back from it.
This is the full stack trace -
TypeError: Cannot read properties of undefined (reading '__knexUid')
at Client_PG.releaseConnection (/app/node_modules/knex/lib/client.js:344:58)
at Transform.<anonymous> (/app/node_modules/knex/lib/execution/runner.js:72:19)
at Transform.emit (node:events:529:35)
at emitCloseNT (node:internal/streams/destroy:132:10)
at emitErrorCloseNT (node:internal/streams/destroy:117:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
As you can see, the error is form the stream method, which invokes releaseConnection where its this.connection is undefined