Skip to content

Bug: process does not exit on Ctrl+C — serve() polling loop keeps process alive with no signal handler #115

Description

@momics

Bug

When node.serve() is called, the rawServe() polling loop keeps an unresolved Promise alive. This prevents the Deno (and Node.js) process from exiting naturally, even after all user code has finished.

There is no default SIGINT handler registered, so pressing Ctrl+C does not stop the process.

Reproduction

const node = await createNode();
node.serve((req) => new Response("hello"));
// process hangs forever — Ctrl+C does nothing

The only ways to exit are:

  • Pass an AbortSignal to serve({ signal }) and abort it manually
  • Call node.close() explicitly

Neither is documented as required.

Expected behaviour

At minimum, the documentation and/or the getting-started example should show that node.close() / an AbortSignal is required for the process to exit.

Ideally, iroh-http should register a default SIGINT/SIGTERM handler (similar to how Deno.serve() handles this) so that Ctrl+C gracefully shuts down the serve loop and exits. This could be opt-out:

node.serve({ handleSignals: true }, (req) => new Response("hello"));

Affected platforms

  • Deno (verified)
  • Node.js (likely same issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdxDeveloper experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions