{"record":{"id":"3dc17ed5e676802a","repo":"gatsbyjs/gatsby","slug":"unhandled-rejection-3dc17e","errorCode":null,"errorMessage":"Unhandled rejection","messagePattern":"Unhandled rejection","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/gatsby/src/utils/worker/reporter.ts","lineNumber":25,"sourceCode":"): void {\n  if (typeof reporter._initReporterMessagingInMain === `function`) {\n    reporter._initReporterMessagingInMain(workerPool.onMessage.bind(workerPool))\n  }\n}\n\nconst gatsbyWorkerMessenger = getMessenger()\nexport function initReporterMessagingInWorker(): void {\n  if (\n    isWorker &&\n    gatsbyWorkerMessenger &&\n    typeof reporter._initReporterMessagingInWorker === `function`\n  ) {\n    reporter._initReporterMessagingInWorker(\n      gatsbyWorkerMessenger.sendMessage.bind(gatsbyWorkerMessenger)\n    )\n\n    process.on(`unhandledRejection`, (reason: unknown) => {\n      reporter.panic((reason as Error) || `Unhandled rejection`)\n    })\n\n    process.on(`uncaughtException`, function (err) {\n      reporter.panic(err)\n    })\n  }\n}\n","sourceCodeStart":7,"sourceCodeEnd":33,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/worker/reporter.ts#L7-L33","documentation":"Default panic message when a worker process reports an unhandledRejection with a falsy reason. In `initReporterMessagingInWorker`, only inside a gatsby-worker context, the process installs an `unhandledRejection` handler that calls `reporter.panic(reason || 'Unhandled rejection')` and an `uncaughtException` handler that panics on the error. So this string surfaces only when a promise rejected with `undefined`/`null`/`''` inside a Gatsby worker.","triggerScenarios":"Code running inside a Gatsby worker (page renderer, parcel compile worker, etc.) rejects a promise with no value: `Promise.reject()` or `throw undefined`, or an async function completes without a value where a rejection was expected. The worker's unhandledRejection handler converts the falsy reason into this generic message.","commonSituations":"A plugin or user code in gatsby-node that does `reject()` with no argument inside a worker; an await on a function that returns undefined and is misused; native/worker IPC delivering an empty rejection; third-party code that swallows the error value.","solutions":["Search the stack trace printed above the panic for the worker file/line that rejected without a value.","Ensure all rejections carry a real Error: `throw new Error('...')` / `reject(new Error('...'))`.","If the origin is a plugin, update it or open an issue with the trace.","Run with `--verbose` and `--inspect-brk` on the worker to capture the rejection site."],"exampleFix":"// before\nfunction load(x) {\n  if (!x) return Promise.reject()\n}\n// after\nfunction load(x) {\n  if (!x) return Promise.reject(new Error(`load() requires a value, got ${x}`))\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isNonEmptyError(reason) {\n  return reason instanceof Error || (typeof reason === 'string' && reason.length > 0)\n}","tryCatchPattern":"// Top-of-worker guard: never let a falsy rejection reach the generic handler.\nprocess.on('unhandledRejection', reason => {\n  const err = isNonEmptyError(reason) ? reason : new Error('Unhandled rejection with empty reason')\n  reporter.panic(err)\n})","preventionTips":["Always reject/throw real Error objects with descriptive messages.","Add a global `process.on('unhandledRejection', ...)` in worker entrypoints that upgrades falsy reasons to an Error with a stack.","Run workers with --inspect-brk and 'trace unhandled' to find the rejection site.","Audit plugins/user code for bare `reject()` calls."],"tags":["worker","unhandled-rejection","promise","debugging"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}