Skip to content

IOApp and leaked fibers #2630

@armanbilge

Description

@armanbilge

While testing http4s/http4s#5657 on Node.js we encountered a strange "bug": the IOApp would terminate, but the Node.js process wouldn't. The same program terminated normally on JVM.

With the help of fiber dumps 😁 we were able to identify some leaked fibers. The app wasn't blocked per-say (IOApp#run had already terminated and set the exit code) but Node.js by default won't terminate the process until the event loop queue is empty (including scheduled events). So as long as those fibers were alive so would be the process.

So overall this was a net win, but this behavior was confusing. Also I'm trying really hard to have identical semantics across JVM/Node.js as much as possible (browsers are another story of course).

Some ideas:

  1. Leave as-is. These are different platforms after all. Plus I can argue that cross-building for Node.js helps find bugs 😉
  2. Force exit on Node.js after IOApp#run terminates, leaks be damned.
  3. Try and match the behavior on JVM? This seems hard in general and is not a good UX anyway.
  4. Hard-exit on both platforms, but maybe issue a best-effort warning about leaked fibers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions