{"record":{"id":"32f897648b84eba5","repo":"gatsbyjs/gatsby","slug":"received-message-about-completed-job-that-wasn-t-s","errorCode":null,"errorMessage":"Received message about completed job that wasn't scheduled by this worker","messagePattern":"Received message about completed job that wasn't scheduled by this worker","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/utils/jobs/worker-messaging.ts","lineNumber":84,"sourceCode":"/**\n * This map is ONLY used in worker. It's purpose is to keep track of promises returned to plugins\n * when creating jobs (in worker context), so that we can resolve or reject those once main process\n * send back their status.\n */\nconst deferredWorkerPromises = new Map<\n  InternalJob[\"id\"],\n  pDefer.DeferredPromise<Record<string, unknown>>\n>()\nconst gatsbyWorkerMessenger = getMessenger()\nexport function initJobsMessagingInWorker(): void {\n  if (isWorker && gatsbyWorkerMessenger) {\n    gatsbyWorkerMessenger.onMessage(msg => {\n      if (msg.type === MESSAGE_TYPES.JOB_COMPLETED) {\n        const { id, result } = msg.payload\n        const deferredPromise = deferredWorkerPromises.get(id)\n\n        if (!deferredPromise) {\n          throw new Error(\n            `Received message about completed job that wasn't scheduled by this worker`\n          )\n        }\n\n        deferredPromise.resolve(result)\n        deferredWorkerPromises.delete(id)\n      } else if (msg.type === MESSAGE_TYPES.JOB_FAILED) {\n        const { id, error, stack } = msg.payload\n        const deferredPromise = deferredWorkerPromises.get(id)\n\n        if (!deferredPromise) {\n          throw new Error(\n            `Received message about failed job that wasn't scheduled by this worker`\n          )\n        }\n\n        const errorObject = new WorkerError(error)\n        if (stack) {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/utils/jobs/worker-messaging.ts#L66-L102","documentation":"initJobsMessagingInWorker looks up the deferred promise registered when this worker scheduled a job, but none exists for the completed job id — meaning the main process reported completion for a job this worker never created (or already handled). An internal messaging-consistency guard.","triggerScenarios":"Thrown at packages/gatsby/src/utils/jobs/worker-messaging.ts:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check for duplicate worker messaging initialization","Report as a Gatsby bug with the job id and plugin involved","Ensure jobs API is used only through the official jobs manager"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}