node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

SASL: Last message was not SASLResponse

Open gdaybrice opened this issue 1 year ago • 7 comments

Hi, I'm using node-pg in a serverless environment and I often see the following error:

Unhandled Rejection: Error: SASL: Last message was not SASLResponse
at /var/task/apps/lawy/.next/server/chunks/9840.js:1:2550
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async a.acquireConnection (/var/task/apps/lawy/.next/server/chunks/9840.js:1:58997)

I can see in code that it gets called in finalizeSession https://github.com/brianc/node-postgres/blob/e25428c8dceb86eb4277af90155295fd0188abce/packages/pg/lib/crypto/sasl.js#L62

When would this error happen?

Thanks for your help.

gdaybrice avatar May 23 '24 23:05 gdaybrice

Hey @blechatellier - i need more code to reproduce this issue. if you can reproduce this in an isolated environment & provide the code I'm more than happy to take a look. Otherwise...not sure? Could be pg-bouncer? Or some misconfigured password somewhere?

brianc avatar Jun 03 '24 15:06 brianc

Also having this problem - in a serverless function.

jonnicholson94 avatar Jun 23 '24 08:06 jonnicholson94

i need more code to reproduce this issue. if you can reproduce this in an isolated environment & provide the code I'm more than happy to take a look.

@jonnicholson94 - any way you could share with me some code that reproduces the problem? 🙏

brianc avatar Jun 24 '24 20:06 brianc

@brianc sorry for the late reply, some of those issues were because of the supabase pooler terminating some connections randomly, the issue has been fixed on their side and this hasn't happened since.

gdaybrice avatar Jun 25 '24 10:06 gdaybrice

I am also using supabase in my project facing this problem. I am still having this issue. Cloud you tell me how to fix this? @blechatellier

fengkx avatar Jun 26 '24 03:06 fengkx

It was related to a change they did and fixed on their side https://github.com/supabase/supavisor/issues/344

gdaybrice avatar Jun 26 '24 03:06 gdaybrice

I've also encountered that issue in the past with an onCompletion callback from streaming an AI response that was called async after the connection was closed.

gdaybrice avatar Jun 26 '24 03:06 gdaybrice