Skip to content

The node adapter registers a SIGINT handler and so the process doesn't always exit on ctrl+C #57

@giladgd

Description

@giladgd

What version of Elysia is running?

1.4.25

What version of Node Adapter are you using?

1.4.5

What platform is your computer?

Darwin 25.3.0 arm64 arm

What steps can reproduce the bug?

import http from "node:http";
import {Elysia} from "elysia";
import {node} from "@elysiajs/node";


const isBun = process.versions.bun != null;

const server = new Elysia({
    adapter: isBun
        ? undefined
        : node()
});

const server2 = http.createServer(console.log);
// const server3 = http.createServer(console.log);

console.log("SIGINT listeners:", process.listeners("SIGINT").length);
server.listen(3000);
server2.listen(3001);
// server3.listen(3002);

console.log("Servers started");
console.log("SIGINT listeners:", process.listeners("SIGINT").length);

// BTW this also doesn't work in node:
// server.stop()

Run it using npx vite-node ./src/repro.ts, then after it loads, try exiting via ctrl+C and see that it doesn't exit.
If you comment out the server.listen(3000); line, you could exit normally.
The issue seems to be that Elysia registers a SIGINT listener by itself, but I couldn't find where in a quick glance (it's probably from some dependency).

What is the expected behavior?

Starting an Elysia server shouldn't take control of SIGINT handling, to not conflict with other things running in the process.

This issue is only relevant to the node adapter and doesn't happen with Bun.

What do you see instead?

When pressing ctrl+C, the server stops but the process doesn't exit.
Pressing again and again still doesn't help and the terminal gets filled with ^C text.

Additional information

Elysia is amazing and it has everything I ever wanted in an HTTP framework and so much more.
Thank you for making it!

Have you try removing the node_modules and bun.lockb and try again yet?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions