Skip to content

"sonic boom is not ready yet" from immediate process.exit #2326

@joshkel

Description

@joshkel

If a process creates a Pino logger then immediately exits via process.exit, then it throws an error similar to the following:

/Users/josh/tmp/node_modules/.pnpm/[email protected]/node_modules/sonic-boom/index.js:541
    throw new Error('sonic boom is not ready yet')
          ^

Error: sonic boom is not ready yet
    at SonicBoom.flushSync (/Users/josh/tmp/node_modules/.pnpm/[email protected]/node_modules/sonic-boom/index.js:541:11)
    at autoEnd (/Users/josh/tmp/node_modules/.pnpm/[email protected]/node_modules/pino/lib/tools.js:315:12)
    at callRefs (/Users/josh/tmp/node_modules/.pnpm/[email protected]/node_modules/on-exit-leak-free/index.js:55:7)
    at process.onExit (/Users/josh/tmp/node_modules/.pnpm/[email protected]/node_modules/on-exit-leak-free/index.js:39:3)
    at process.emit (node:events:518:28)
    at process.exit (node:internal/process/per_thread:194:15)
    at file:///Users/josh/tmp/test.mts:8:9
    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:647:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Test case:

import { destination, pino } from "pino";

const logger = pino(
  { level: "debug", name: "Test Case" },
  destination({ dest: "log.txt" })
);
logger.debug("This is a debug message");
process.exit(0);

Observed in Pino 10.1.0 with sonic-boom 4.2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions