-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node::net.Socket()
reusing socket works on NodeJS but fails in Bun
#7325
Comments
It seem this is still the issue on the latest version
|
For anyone else who lands here with an issue using postgres-js on Bun, |
Hmm... the issue with Postgres.js not properly closing the connection for me is present even in Bun v1.1.8. Are you sure @Jarred-Sumner that it is fixed? Looks like I'm not the only one: porsager/postgres#817 (comment) |
Hi, may I have the code you are using to test it and also perhaps the postgresql config if any (maybe such us timeout and such), I want to test it on my end (which I know probably behave the same) and also trying some workaround I'm currently trying as well to validate it Also can confirm, for me it has higher chance of the issue being triggered when the server was idling |
@deanrih Add your posgres db url in .env file. Here is the screenshot of requests i made to the server. Check the time difference also. DB read request after 25 Mins got me this error. Also, i didn't got any error in locally hosted prostres. (for 30 mins) |
Oh wow, sorry for the late reply, and thank you, didn't expect for my dummy test repo to be used and kinda forgot about it (playing around with the local copy), will try it soon |
This issue seems fixed in bun 1.1.39 👍🏼 |
What version of Bun is running?
1.0.13
What platform is your computer?
Darwin 22.6.0 arm64 arm
What steps can reproduce the bug?
Reusing a client socket connection works in Node.JS - but fails in Bun.
Reusing means that we close the connection at some point for some reasons then we try to reconnect and reuse the socket.
This use case is often implemented in database clients to avoid stale socket issues.
Test script - you should have a simple echo TCP server running
What is the expected behavior?
No error (like in node)
![image](https://private-user-images.githubusercontent.com/135170502/285653254-a47ec7fa-73cb-4271-9f1c-bfd5bac869e9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODEwODcsIm5iZiI6MTczOTE4MDc4NywicGF0aCI6Ii8xMzUxNzA1MDIvMjg1N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NTEzZjc3ZTAzMjNkNzVmNDc1OTdkYTE5Y2EyYTI1MDAwZjBhMzk0OWY4MTM5ZjJmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.vX8GlXWj8AOT1Qc8LZh8HP-vhuLMZc3AVgXKFtTFsRU)
What do you see instead?
It fails with Bun
![image](https://private-user-images.githubusercontent.com/135170502/285653392-26b1ef49-99d3-4c63-ab05-a7f239f211bc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODEwODcsIm5iZiI6MTczOTE4MDc4NywicGF0aCI6Ii8xMzUxNzA1MDIvMjg1NjUzMzkyLTI2YjFlZjQ5LTk5ZDMtNGM2My1hYjA1LWE3ZjIzOWYyMTFiYy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQwOTQ2MjdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05NjhlZjY3Nzg1NWExMWY2YzhjZDIwY2JjNWYxNTlmMTY1YjgzZDhhMTAzMzNmZTJmNTMwOGU4MWUyMjQ3YmRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.1jx3gq5MGk3D9LDsePRIrxvunqJACvuZbOUYfiu56PI)
Additional information
Found this while debugging a pretty famous node module that froze over a period of time in Bun but worked flawlessly on Node.JS.
A solution we found to bypass this error was to recreate a
new.Socket()
each time after a socket "ended" (instead of reusing the same socket)The text was updated successfully, but these errors were encountered: