The script will never generate a response
Ok that's not the reason, it's not working in production either. Creating a thread to paste the code. (Sorry for tagging: @kian)
7 Replies
index.ts
apiRouter.ts
This is resulting in the following error:
Replacing "Client" with "Pool" does work.
But not the recommended way (if I'm reading this message correctly):
https://discord.com/channels/595317990191398933/1150557986239021106/1184899420119122011
Without replacing this and using pg.connect(), it works. But this shouldn't be needed in production, since Hyperdrive is pooling for us - and the connection is being destroyed when the Worker is finished.
Just seems like you missed out
await pg.connect();
before the query.Ah I thought you where talking about not needing that.
https://discord.com/channels/595317990191398933/1150557986239021106/1184899420119122011
Do I need to close it?
In your
client
example you had await client.connect()
You don't necessarily need to close it, Hyperdrive will handle that.Yeah, sorry. Just misunderstanding your reaction then. Thanks for answering.
The way that Hyperdrive works is that your Worker connects to Hyperdrive on each request (which is a quick round-trip) and Hyperdrive keeps a connection open to your database.