unexpected errors
Hey team, I'm seeing an elevated amount of
Error: Connection terminated unexpectedly
in our setup (hyperdrive enabled). We did ship some changes recently that increased some calls within a waitUntil
function. Could that code be the reason why we are seeing more of these errors?12 Replies
Hi! We are not currently sending out a release, nor am I seeing any widespread instability right now.
Without knowing quite a lot about your setup and what exactly was added to your
Without knowing quite a lot about your setup and what exactly was added to your
waitUntil
calls I'm not sure I could answer that.So our waitUntil setup is like this:
I’m not the best with nested waitUntil, but I’m wondering if I’m not awaiting somewhere to ensure the connection stays open until everything is finished?
thanks again!
Hmmmm. Yeah, this sort of JS code isn't my specialty either, tbh. On a quick read through nothing about this is obviously wrong to me, though.
One way you could try to resolve this is to add a
waitUntil(db.close())
(or whatever the correct syntax is for explicitly closing your connection with your driver/ORM) to ensure you properly disconnect after it's all said and done.hmmm, yeah. that's helpful. I'm realizing it might be something with our db connection code rather than our busines logic. I'll do more investigating. thank you!
Hey, I'm seeing something similar, in my case there was no update on the code, was there any change on hyperdrive limits?
Every big insert (2500+ values) gets "write CONNECTION_CLOSED" on postgres.js, but previously (before dec 3) this very same inserts were working flawlessly.
Also those inserts work ok on local dev using the same database as in production
No, we didn't make any changes of that nature, but that's an excellent bit of info to dig into it. Thanks for sharing that.
I'll take a look.
Obvious question here, but no changes to driver version or anything like that?
2500+ here meaning rows or columns?
Nope, always postgres 3.4.5
I'm using this code to test and apparently nailed it down to 2046+ values (2045 works ok, 2046+ hangs and ends up in "write CONNECTION_CLOSED"), I have other inserts failing with less rows (~500) but over 11 columns
Ok, that's incredibly helpful, thank you. I'll pass all this over to the team and start digging.
awesome, thank you!
@Iván This should be fixed now. Please check and confirm, if you would?
Thank you again for the incredibly valuable repro. I wish all bugs came with one of those.
There'll be some followup work to do off this, but hopefully this unblocks folks for now.
Yeees! Working now! thanks a lot!
As a heads up, we need to walk back that fix. There's some other related challenges, and we need to rework how it was done to be more efficient. You're going to see that issue again for a bit until we can get it re-done in a more complete way. I apologize for this inconvenience.
Alright, holistic fix is out now. Should be done with this issue.