neondatabase / serverless

Connect to Neon PostgreSQL from serverless/worker/edge functions
https://www.npmjs.com/package/@neondatabase/serverless
MIT License
343 stars 13 forks source link

When no `connect()` is called in `pg-node` driver we are not intercepting connection (looks like it) #2

Closed kelvich closed 1 year ago

kelvich commented 1 year ago

Steps to reproduce

https://twitter.com/_alexblokh/status/1602397018445516807

didn't try to reproduce myself though

jawj commented 1 year ago

I'll look into this today.

jawj commented 1 year ago

I can reproduce this not working ... but it also doesn't work for me with vanilla node-postgres (npm install pg). Normal behaviour seems to be that you can query prior to connect, but returned promises remain pending until you connect.

Node session:

> client = new pg.Client(URL)
Client { ... }

> client.query('select now()')
  .then(r => console.log('result', r))
  .catch(e => console.log('error', e))
Promise { <pending>, ... }

// wait a while ...

> client.connect()
Promise { <pending>, ... }

result Result { rows: ... }

Tweeted: https://twitter.com/jawj/status/1602667209591078914, https://twitter.com/jawj/status/1602668515718225924

jawj commented 1 year ago

OK, I'm closing this. The driver seems to behave the same way as ordinary pg when calling query before connect on Client. And calling query on Pool also seems to work fine.

Tweets: https://twitter.com/_alexblokh/status/1602740964627456004, https://twitter.com/jawj/status/1602804020392992768, https://twitter.com/_alexblokh/status/1602904839939317760