{"id":"83e27114427628aa","repo":"jestjs/jest","slug":"child-can-only-be-used-on-a-forked-process-83e271","errorCode":null,"errorMessage":"Child can only be used on a forked process","messagePattern":"Child can only be used on a forked process","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-worker/src/workers/threadChild.ts","lineNumber":101,"sourceCode":"            reportInitializeError,\n          );\n        } else {\n          reportSuccess(void 0);\n        }\n      }\n      break;\n\n    default:\n      throw new TypeError(\n        `Unexpected request from parent process: ${request[0]}`,\n      );\n  }\n};\nparentPort!.on('message', messageListener);\n\nfunction reportMemoryUsage() {\n  if (isMainThread) {\n    throw new Error('Child can only be used on a forked process');\n  }\n\n  const msg: ParentMessageMemUsage = [\n    PARENT_MESSAGE_MEM_USAGE,\n    process.memoryUsage().heapUsed,\n  ];\n\n  parentPort!.postMessage(msg);\n}\n\nfunction reportSuccess(result: unknown) {\n  if (isMainThread) {\n    throw new Error('Child can only be used on a forked process');\n  }\n\n  try {\n    parentPort!.postMessage([PARENT_MESSAGE_OK, result]);\n  } catch (error) {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-worker/src/workers/threadChild.ts#L83-L119","documentation":"Error \"Child can only be used on a forked process\" thrown in jestjs/jest.","triggerScenarios":"Thrown at packages/jest-worker/src/workers/threadChild.ts:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This setup code only runs in a worker thread spawned by jest-worker. It was executed outside a worker thread; run the code through Jest's worker farm instead of invoking the thread script directly."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}