{"record":{"id":"807ebd1916e346fa","repo":"pinojs/pino","slug":"missing-bindings-for-child-pino-807ebd","errorCode":null,"errorMessage":"missing bindings for child Pino","messagePattern":"missing bindings for child Pino","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/proto.js","lineNumber":87,"sourceCode":"  get [Symbol.toStringTag] () { return 'Pino' },\n  [lsCacheSym]: initialLsCache,\n  [writeSym]: write,\n  [asJsonSym]: asJson,\n  [getLevelSym]: getLevel,\n  [setLevelSym]: setLevel\n}\n\nObject.setPrototypeOf(prototype, EventEmitter.prototype)\n\n// exporting and consuming the prototype object using factory pattern fixes scoping issues with getters when serializing\nmodule.exports = function () {\n  return Object.create(prototype)\n}\n\nconst resetChildingsFormatter = bindings => bindings\nfunction child (bindings, options) {\n  if (!bindings) {\n    throw Error('missing bindings for child Pino')\n  }\n  const serializers = this[serializersSym]\n  const formatters = this[formattersSym]\n  const instance = Object.create(this)\n\n  // If an `options` object was not supplied, we can improve\n  // the performance of child creation by skipping\n  // the checks for set options and simply return\n  // a baseline instance.\n  if (options == null) {\n    if (instance[formattersSym].bindings !== resetChildingsFormatter) {\n      instance[formattersSym] = buildFormatters(\n        formatters.level,\n        resetChildingsFormatter,\n        formatters.log\n      )\n    }\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/pinojs/pino/blob/5aa62305c57709ebd6f6b7c328e8830eeb29b297/lib/proto.js#L69-L105","documentation":"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.","triggerScenarios":"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.","commonSituations":"Refactors that removed the bindings argument; passing an optional config object that is unset; wrappers around pino that forward an empty argument list.","solutions":["Pass an object, even an empty one: logger.child({}).","Ensure the variable holding bindings is defined and an object before calling child().","If no bindings are needed, use the parent logger directly or child({}).","In wrappers, default the argument: child(bindings || {})."],"exampleFix":"// before\nconst child = logger.child()\n// after\nconst child = logger.child({ requestId: req.id })","handlingStrategy":"validation","validationCode":"function safeChild(logger, bindings) {\n  if (bindings == null || typeof bindings !== 'object') {\n    throw new TypeError('child() requires a bindings object')\n  }\n  return logger.child(bindings)\n}","typeGuard":"function isBindings(v) {\n  return v != null && typeof v === 'object' && !Array.isArray(v)\n}","tryCatchPattern":"try {\n  child = logger.child(bindings)\n} catch (e) {\n  if (e.message === 'missing bindings for child Pino') {\n    child = logger.child({})\n  } else throw e\n}","preventionTips":["Always pass an object literal to .child(), even when empty: child({}).","Default optional binding variables: child(bindings || {}).","Keep a single helper for child creation so the bindings argument is never dropped.","Type-check bindings (plain object) before calling child() in wrappers."],"tags":["api-misuse","logging","child-logger"],"backgroundTag":"missing-required-argument","analyzedSha":"5aa62305c57709ebd6f6b7c328e8830eeb29b297","analyzedAt":"2026-09-02T22:05:21.418Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}