-
-
Notifications
You must be signed in to change notification settings - Fork 365
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.3.1
What platform is your computer?
Darwin 24.4.0 arm64 arm
What steps can reproduce the bug?
- Create a file index.js with the following content:
import { sleep } from 'bun';
import { Elysia } from 'elysia';
const app = new Elysia()
.get('/', async () => {
await sleep(5000);
return 'Hello World';
})
.listen(3000);
console.log('Server is running');
process.on('SIGINT', () => {
console.log('Received SIGINT. Stopping server...');
app.stop().then(() => {
console.log('Server stopped');
process.exit(0);
});
});
- Run the server.
- In another terminal or browser, issue a request to the server:
curl http://localhost:3000
- Immediately press Ctrl+C in the server’s terminal to send SIGINT.
What is the expected behavior?
- On SIGINT, app.stop() should wait for any in-flight handlers (e.g. the 5s sleep) to resolve.
- After the handler completes, the server should send the response ("Hello World") and then shut down gracefully.
What do you see instead?
- The server logs Received SIGINT. Stopping server…
- Process exits instantly.
- The pending request is aborted; the client never receives "Hello World".
Additional information
This Bun example correctly waits for the 5s delay before sending the response, then exits.
const server = Bun.serve({
port: 3000,
async fetch() {
await sleep(5000);
return new Response('Hello World');
},
});
console.log('Server is running');
process.on('SIGINT', () => {
console.log('Received SIGINT. Stopping server...');
server.stop().then(() => {
console.log('Server stopped');
process.exit(0);
});
});
Have you try removing the node_modules
and bun.lockb
and try again yet?
Yes
LeTamanoir
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working