{"id":"9b642282a7077144","repo":"jestjs/jest","slug":"child-can-only-be-used-on-a-forked-process","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/processChild.ts","lineNumber":98,"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};\nprocess.on('message', messageListener);\n\nfunction reportSuccess(result: unknown) {\n  if (!process || !process.send) {\n    throw new Error('Child can only be used on a forked process');\n  }\n\n  try {\n    process.send([PARENT_MESSAGE_OK, result]);\n  } catch (error) {\n    if (\n      isError(error) &&\n      // if .send is a function, it's a serialization issue\n      !error.message.includes('.send is not a function')\n    ) {\n      // Apply specific serialization only in error cases\n      // to avoid affecting performance in regular cases.\n      process.send([PARENT_MESSAGE_OK, packMessage(result)]);\n    } else {\n      throw error;\n    }\n  }\n}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-worker/src/workers/processChild.ts#L80-L116","documentation":"Error \"Child can only be used on a forked process\" thrown in jestjs/jest.","triggerScenarios":"Thrown at packages/jest-worker/src/workers/processChild.ts:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This setup code only runs in a process forked by jest-worker. It was executed in a non-forked process; run the code through Jest's worker farm instead of invoking the child 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}