Skip to content

TT-019: Node SDK's unhandledRejection handler stops Node's default crash (process keeps running, exit 0), with no opt-out #719

Closed

Description

@unjica

Severity: P2 · Area: SDK: Node · Found by: QA

Summary

init() from @telemetry-tracker/node installs a process.on("unhandledRejection") listener that reports the error and returns. Registering any such listener turns off Node's default behaviour, which since Node 15 is to crash with exit code 1. So an app that crashed on an unhandled rejection before adding the SDK keeps running after adding it, and exits 0.

There's no option to keep the default crash, and the docs say the opposite: /docs/node says "(and then rethrow / continue so your process can still exit or log as usual)".

A real-world consequence: in Express 4, an async route that throws leaves the HTTP request hanging (no response), because the process neither crashes nor responds.

Severity reason: P2. It silently changes crash semantics for every Node app that installs the SDK. Processes keep running in an unknown state, and supervisors and orchestrators never restart them. The error itself is reported (not lost), and it isn't a crash-capture failure like #711.

Affected published versions

Environment and versions

2026-09-26 10:40–10:50 CEST. Node 18.20.8, 20.19.2, 22.23.3, 24.21.0, 26.10.0, Linux. Express 4.22.3 / 5.2.1. Local mock ingest.

Steps to reproduce

  1. Run the mock:
    // mock.mjs
    import http from "node:http";
    http.createServer((req, res) => { let b = ""; req.on("data", c => b += c); req.on("end", () => {
      console.log(new Date().toISOString(), req.method, req.url, b.slice(0, 120)); res.writeHead(204).end(); }); }).listen(4318);
  2. npm i @telemetry-tracker/[email protected], then create rejection.mjs:
    import { init } from "@telemetry-tracker/node";
    init({ ingestUrl: "http://127.0.0.1:4318", app: "qa-node", apiKey: "test", environment: "qa" });
    setTimeout(() => Promise.reject(new Error("QA unhandled rejection")), 300);
    setTimeout(() => console.error("still running 2 s after the rejection"), 2300);
  3. node rejection.mjs; echo "exit=$?". Then comment out init(...) and run it again.

Expected

The rejection is reported, and then Node's configured behaviour still applies: exit code 1 by default. At minimum there's an opt-out, and the docs describe what happens.

Actual

Run Rejection reported Process after the rejection Exit code
no SDK (control), Node 18–26 – crashes within 1 ms 1 (5/5)
with SDK (npm 1.3.0), Node 18–26 yes: 2/2 per run (Error and non-Error reason), context.source = "unhandledRejection", received 2–53 ms after the rejection keeps running, prints "still running…" 0 (5/5)
with SDK, server responding after 500 ms / 3 s yes (2/2) keeps running 0
with SDK, endpoint unreachable no (fetch failed) keeps running 0
repo develop build, Node 18–26 yes keeps running 0 (5/5)

Express 4, route app.get("/x", async () => { throw new Error() }) with app.use(middleware()): the request never gets a response (client timed out after 2 s, Node 20/22/24). The error is reported only as unhandledRejection. Express 5 returns 500 (it catches async errors itself).

Workaround: node --unhandled-rejections=strict routes the rejection to uncaughtException. With npm 1.3.0 that then hits #711 (exit 7, not reported).

Root cause

  • npm @telemetry-tracker/[email protected] dist/index.js:11-14: the listener only calls coreTrackError(err, { source: "unhandledRejection" }). installGlobalHandlers() is unconditional (dist/index.js:3-15, called from init at :18).
  • repo packages/telemetry-node/src/index.ts:32-36 (dist dist/index.js:15-18): the same.
  • TelemetryConfig (core src/index.ts) has no option to skip or change the handlers.

Release coordination

Node package only (for example an exitOnUnhandledRejection / captureUnhandledRejections option, defaulting to Node's behaviour: report, flush via flushFatalError, exit 1). If it reuses flushFatalError/ingestError, it depends on the same core release as #711: core first, then node with ^<new core>. Ship it in the same node release as #711 if possible. The docs (/docs/node, /error-tracking/nodejs, docs/sdk-node.md) must describe the chosen behaviour.

Acceptance criteria

With the newly published @telemetry-tracker/node, on Node 20/22/24:

  • rejection.mjs reports exactly one /ingest/error with source: unhandledRejection, then exits non-zero (or, if "keep running" is the default, the docs say so and an option restores the crash, verified both ways);
  • under --unhandled-rejections=strict, the error is reported and the process exits 1;
  • the Express 4 async-throw route doesn't hang indefinitely when the option is enabled (process exits, so the supervisor restarts it).

Fix references

None yet.

History

  • 2026-09-26 10:40–10:50 CEST: found and reproduced (25 SDK runs + 5 controls, Node 18–26; Express 4/5).

Filed from the QA regression list on 2026-09-26. Source: QA report 2026-09-26-sdk-qa.md (#tt-019).

Activity

  1. added
    bug
    sdk
    qa
    on Sep 26, 2026
  2. unjica commented on Oct 2, 2026

    @unjica
    CollaboratorAuthor

    QA verification — PASS (closed)

    When: 2026-10-02 ~08:56 CEST (weekday smoke)
    Fix: PR #722 → @telemetry-tracker/[email protected] (depends on core ^1.5.0; resolved 1.5.1)
    Method: Fresh registry install. unhandledRejection script ×2 against production; control without SDK.

    Case Exit Still alive @3s Error ingested
    Control (no SDK) 1 no n/a
    SDK r1 1 no yes
    SDK r2 1 no yes

    Published dist defaults exitOnUnhandledRejection to true and uses flushFatalError for rejections. Closing as verified-fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugqasdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions