kysely-org / kysely-postgres-js

Kysely dialect for PostgreSQL using the Postgres.js client.
MIT License
66 stars 3 forks source link

Getting Cannot read properties of undefined (reading 'replace') error #9

Closed geekyayush closed 10 months ago

geekyayush commented 10 months ago

I am getting this error. My setup is same as given in the readme example. I am using RDS proxy on AWS.

ERROR Uncaught Exception {"errorType":"TypeError","errorMessage":"Cannot read properties of undefined (reading 'replace')","stack":["TypeError: Cannot read properties of undefined (reading 'replace')"," at queryError (file:///var/task/packages/functions/src/my-lambda.mjs:807408:49)"," at errored (file:///var/task/packages/functions/src/my-lambda.mjs:807403:17)"," at Socket.error (file:///var/task/packages/functions/src/my-lambda.mjs:807395:5)"," at Socket.emit (node:events:517:28)"," at Socket.emit (node:domain:489:12)"," at emitErrorNT (node:internal/streams/destroy:151:8)"," at emitErrorCloseNT (node:internal/streams/destroy:116:3)"," at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"]}

igalklebanov commented 10 months ago

Hey 👋

What node runtime are you using in your lambda? What versions of kysely, postgres, kysely-postgres-js are you using? Can you share a non-bundled stack trace?

geekyayush commented 10 months ago

What node runtime are you using in your lambda? What versions of kysely, postgres, kysely-postgres-js are you using? Can you share a non-bundled stack trace?

@igalklebanov

Node runtime: Node 18x Versions:

"kysely": "^0.26.3",
postgres: 3.4.3
kysely-postgres-js: 2.0.0

Since I am using RDS proxy, I cannot connect from my localhost, and thus cannot generate the non-bundled stack trace. I am using sst.dev framework for deployment. My localhost postgres just work fine.

I also tried the postgres Dialact that comes in kysely. It's also having problem connecting to the RDS proxy. That dialact is throwing the following error: "Connection terminated unexpectedly".

and I found this github issue regarding same: https://github.com/brianc/node-postgres/issues/2112

So I suspect it's something to do with the RDS proxy. but still, I could not find any solution. If I remove RDS proxy and directly use RDS db, then it works fine.

If you faced something similar, and could help me, I would greatly appreciate. ^_^

igalklebanov commented 10 months ago

SST projects are notorious for having multiple kysely versions installed. I suspect this is your issue. SST core uses kysely 0.25.x afaik. You could switch to pnpm/yarn or find a way to deduplicate your kysely dependency in node_modules.

This seems unrelated to this dialect.

geekyayush commented 10 months ago

SST projects are notorious for having multiple kysely versions installed. I suspect this is your issue. SST core uses kysely 0.25.x afaik. You could switch to pnpm/yarn or find a way to deduplicate your kysely dependency in node_modules.

Thanks for your reply. I will check that.