-
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
SQL from bun gets timeouts very easly #16892
Comments
Just to let you know... the issue still persists on 1.2.2. |
Can you send a repro? import { Elysia } from "elysia";
import { SQL } from "bun";
const sql = new SQL({
url: "postgresql://bun:bunbunbun@localhost:5432/bun",
idleTimeout: 5,
});
new Elysia({ serve: { idleTimeout: 10 } })
.get("/", async () => {
const res = await sql`SELECT * FROM "users" limit 1`;
return { rows: res };
})
.listen(3000, () => {
console.log("Server is running on port 3000");
});
await fetch("http://localhost:3000/")
.then(res => res.json())
.then(console.log);
await Bun.sleep(10_000);
await fetch("http://localhost:3000/")
.then(res => res.json())
.then(console.log); Output using Output using |
Just one file... using the simple code: import { Elysia } from 'elysia'
import { SQL } from 'bun'
// import postgres from 'postgres'
const sql = new SQL({ url: process.env.DATABASE_URL, max: 10, idleTimeout: 5 });
// const sql = postgres(process.env.DATABASE_URL, { max: 10, idle_timeout: 5});
new Elysia({ serve: { idleTimeout: 10 } })
.get('/', async () => {
const res = await sql`SELECT * FROM cidades`;
return { rows: res };
})
.listen(3000, () => {
console.log('Server is running on port 3000');
}); I just tested on Linux as well... same result. Here is a new video showing the case. |
And, another information that I belive may be relevant... using K6, before, I use to get alot of timeouts... now, I get none... but, if I send the request slowly like in the video.... the problem happens. |
@belizariogr running on Windows, Linux or MacOS I cannot reproduce this when using |
Im running this also in localhost. |
You are using Postgres 17 right? maybe this is the problem Im testing with 14, 15 and 16 will try with 17 tomorrow will reopen the Issue and investigate further |
And, if was a IPv6/v4 problem of some sort... the problem should be happing on the posgres driver as well. |
Yes... Postgres 17. |
can confirm, with lots of data |
Ok got the repro will work on this tomorrow, Thank you @belizariogr |
Just tested on Postgres 16... and have the same result... but, limiting the results on 1 record... no issues... The problem is related with large result set.... apparently. |
Testing here... the problem only happens when the result set is more than 100 KB.... If is less than that... no issues. |
this makes sense as even if you increase timeout to something huge, it never actually finishes. |
What version of Bun is running?
1.2.1
What platform is your computer?
Windows x64, Linux x64
What steps can reproduce the bug?
Using the SQL from "bun", the server hangs and returns:
Idle timeout reached after 5s
changing the driver for the "postgres" (that the native driver is based on) the problem does not happening.
Here is a video showing the issue happening.
https://youtu.be/tjbe4-xixUk
What is the expected behavior?
Return the records all the time.
What do you see instead?
Hangs and gets timeout.
Additional information
Tested on Windows x64 and Linux (Ubuntu 24.04), PostgreSQL 17.
The text was updated successfully, but these errors were encountered: