P
Prisma6mo ago
Max

Prisma PG adapter error in hosted environments (`this.client.connect(...).catch is not a function`)

TypeError: this.client.connect(...).catch is not a function
File "/app/node_modules/@prisma/adapter-pg/dist/index.js", line 584, col 51, in PrismaPgAdapter.startTransaction
const conn = await this.client.connect().catch((error) => this.onError(error));
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 31668, in #r
File "node:internal/process/task_queues", line 95, col 5, in process.processTicksAndRejections
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 31296, in Or.startTransaction
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 25694, in e.interpretNode
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 23373, in e.run
File "/app/node_modules/@prisma/client/runtime/client.js", line 72, col 2001, in Ft.request
File "/app/node_modules/@prisma/client/runtime/client.js", line 81, col 5885, in Object.singleLoader
File "/app/node_modules/@prisma/client/runtime/client.js", line 81, col 6377, in ni.request
File "/app/node_modules/@prisma/client/runtime/client.js", line 90, col 9782, in l
File "/app/services/xyz/xyz.ts", line 219, col 33, in XyzService_1.XyzService.storeXyz
const xyz = await this.prisma.xyz.create({
TypeError: this.client.connect(...).catch is not a function
File "/app/node_modules/@prisma/adapter-pg/dist/index.js", line 584, col 51, in PrismaPgAdapter.startTransaction
const conn = await this.client.connect().catch((error) => this.onError(error));
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 31668, in #r
File "node:internal/process/task_queues", line 95, col 5, in process.processTicksAndRejections
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 31296, in Or.startTransaction
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 25694, in e.interpretNode
File "/app/node_modules/@prisma/client/runtime/client.js", line 71, col 23373, in e.run
File "/app/node_modules/@prisma/client/runtime/client.js", line 72, col 2001, in Ft.request
File "/app/node_modules/@prisma/client/runtime/client.js", line 81, col 5885, in Object.singleLoader
File "/app/node_modules/@prisma/client/runtime/client.js", line 81, col 6377, in ni.request
File "/app/node_modules/@prisma/client/runtime/client.js", line 90, col 9782, in l
File "/app/services/xyz/xyz.ts", line 219, col 33, in XyzService_1.XyzService.storeXyz
const xyz = await this.prisma.xyz.create({
This is using 6.10.1 with pg 8.16.1, pg-pool 3.10.1 The confusing thing is that this only occurs in the hosted environment on AWS ECS. I've tried building the container image and running it locally and it works just fine. This did not happen with @prisma/adapter-pg 5.22.0. I have tried it both with and without the new queryCompiler preview feature. Is there anything I can do to reproduce this or narrow down the cause?
3 Replies
Prisma AI Help
Prisma AI Help6mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Nurul
Nurul6mo ago
Hey! It would be very helpful if you can provide a minimal reproducible example for this issue. I'll then be able to share it with team internally to investigate
ept
ept3mo ago
I know this is months old, but I ran into the same issue after switching to engineType = "client". I was seeing basically the same stack trace and it was only happening in AWS ECS. For me the issue turned out to be caused by @opentelemetry/instrumentation-pg - it wraps the pg-pool connect method and I guess the wrapper can return a non-Promise which causes this line to throw: https://github.com/prisma/prisma/blob/6.16.2/packages/adapter-pg/src/pg.ts#L200 . It was only happening in ECS because I had instrumentation switched off in dev. Removing the instrumentation resolved the issue for me. If anyone else runs into this I would suggest looking to see if you have any auto- or pg-specific instrumentation switched on.

Did you find this page helpful?