brianc / node-postgres

PostgreSQL client for node.js.
https://node-postgres.com
MIT License
12.07k stars 1.21k forks source link

Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string #3223

Closed itsmikesharescode closed 1 month ago

itsmikesharescode commented 1 month ago

I am using sveltekit + postgreSQL + drizzle ORM + lucia auth v3.

Everything is working but it seems there is a problem with node-pool that is not force to be string ? after awaiting the Client password? idk

image

postgre version: psql (PostgreSQL) 14.11 (Ubuntu 14.11-0ubuntu0.22.04.1) node version: v20.13.1

this is the repo to reproduce the error https://github.com/itsmikesharescode/edge-stack

godbless, hope it gets better.

sehrope commented 1 month ago

That error means the password is not a string. It's probably undefined / missing.

Check if you're actually supply a value for the password field. In your linked code I think it's coming from this env var: https://github.com/itsmikesharescode/edge-stack/blob/336b373a57edb4d935a3359467cc82f5ed391104/src/db/config.ts#L13C31-L13C39

Perhaps VITE_PWS is a typo. Should it be VITE_PWD ("D" suffix)?

brianc commented 1 week ago

If you can provide working code sample that reproduces the issue I am happy to take a look at it. Without that, there isnt a ton i can do to help.

On Fri, Jul 5, 2024 at 10:21 PM Raúl A. Hernández Lafont < @.***> wrote:

Hi, I'm having the same issue using Hono, Drizzle ORM and Lucia. I've hardcoded the db credentials in my drizzle.config.ts and in the instantiation of the pg Pool but the error persists

— Reply to this email directly, view it on GitHub https://github.com/brianc/node-postgres/issues/3223#issuecomment-2211611047, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMHINR7NSID4Q6JXYBFDTZK5PCRAVCNFSM6AAAAABIJD62QKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRGYYTCMBUG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

hagesake commented 1 week ago

Oh sorry for the delay getting back to you but the problem was because when managing sessions with Lucia it performs some actions on the DB and the piece of code doing that was in another file. When spotted the bug and changed the code to use the same instance of the pg connection Pool the bug was no more

itsmikesharescode commented 1 week ago

Oh sorry for the delay getting back to you but the problem was because when managing sessions with Lucia it performs some actions on the DB and the piece of code doing that was in another file. When spotted the bug and changed the code to use the same instance of the pg connection Pool the bug was no more

Sorry i am just beginner so it means the bug is fixed now i can use it again now?

itsmikesharescode commented 1 week ago

If you can provide working code sample that reproduces the issue I am happy to take a look at it. Without that, there isnt a ton i can do to help. On Fri, Jul 5, 2024 at 10:21 PM Raúl A. Hernández Lafont < @.> wrote: Hi, I'm having the same issue using Hono, Drizzle ORM and Lucia. I've hardcoded the db credentials in my drizzle.config.ts and in the instantiation of the pg Pool but the error persists — Reply to this email directly, view it on GitHub <#3223 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMHINR7NSID4Q6JXYBFDTZK5PCRAVCNFSM6AAAAABIJD62QKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRGYYTCMBUG4 . You are receiving this because you are subscribed to this thread.Message ID: @.>

i think the problem is in lucia as hagesake mention sorry for not following rules i am just beginner in github.

hagesake commented 1 week ago

Hi there @itsmikesharescode. I was having this issue but the cause was not to do with Lucia or pg, it was an oversight in my part. When using Lucia to manage user and sessions and Drizzle as the ORM, you need to make sure that the db adapter provided by Lucia is using the db instance generated by Drizzle. In my case is a Postgres connection pool

See in the picture how I imported the db instance in the auth.ts file where the tables for users and sessions are defined. This is where integration between Lucia, Drizzle and the database happens

hagesake commented 1 week ago

lucia-auth