pinojs/pino · error · Error

missing bindings for child Pino

Error message

missing bindings for child Pino

What it means

child(bindings) requires a bindings object to attach context to the child logger. Calling .child() with no argument (or a falsy value like undefined/null) throws, because pino cannot form the child's bindings without it.

Source

Thrown at lib/proto.js:87

  get [Symbol.toStringTag] () { return 'Pino' },
  [lsCacheSym]: initialLsCache,
  [writeSym]: write,
  [asJsonSym]: asJson,
  [getLevelSym]: getLevel,
  [setLevelSym]: setLevel
}

Object.setPrototypeOf(prototype, EventEmitter.prototype)

// exporting and consuming the prototype object using factory pattern fixes scoping issues with getters when serializing
module.exports = function () {
  return Object.create(prototype)
}

const resetChildingsFormatter = bindings => bindings
function child (bindings, options) {
  if (!bindings) {
    throw Error('missing bindings for child Pino')
  }
  const serializers = this[serializersSym]
  const formatters = this[formattersSym]
  const instance = Object.create(this)

  // If an `options` object was not supplied, we can improve
  // the performance of child creation by skipping
  // the checks for set options and simply return
  // a baseline instance.
  if (options == null) {
    if (instance[formattersSym].bindings !== resetChildingsFormatter) {
      instance[formattersSym] = buildFormatters(
        formatters.level,
        resetChildingsFormatter,
        formatters.log
      )
    }

View on GitHub (pinned to 5aa62305c5)

Solutions

  1. Pass an object, even an empty one: logger.child({}).
  2. Ensure the variable holding bindings is defined and an object before calling child().
  3. If no bindings are needed, use the parent logger directly or child({}).
  4. In wrappers, default the argument: child(bindings || {}).

Example fix

// before
const child = logger.child()
// after
const child = logger.child({ requestId: req.id })
Defensive patterns

Strategy: validation

Validate before calling

function safeChild(logger, bindings) {
  if (bindings == null || typeof bindings !== 'object') {
    throw new TypeError('child() requires a bindings object')
  }
  return logger.child(bindings)
}

Type guard

function isBindings(v) {
  return v != null && typeof v === 'object' && !Array.isArray(v)
}

Try / catch

try {
  child = logger.child(bindings)
} catch (e) {
  if (e.message === 'missing bindings for child Pino') {
    child = logger.child({})
  } else throw e
}

Prevention

When it happens

Trigger: logger.child() with zero arguments; logger.child(someVar) where someVar is undefined; conditional code like bindings && logger.child(bindings) inverted so bindings is falsy at runtime.

Common situations: Refactors that removed the bindings argument; passing an optional config object that is unset; wrappers around pino that forward an empty argument list.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pinojs/pino@5aa62305c5 (2026-09-02). Data as JSON: /api/errors/807ebd1916e346fa. Report an issue: GitHub.