jestjs/jest · error · Error

Child can only be used on a forked process

Error message

Child can only be used on a forked process

What it means

Error "Child can only be used on a forked process" thrown in jestjs/jest.

Source

Thrown at packages/jest-worker/src/workers/processChild.ts:98

            reportInitializeError,
          );
        } else {
          reportSuccess(void 0);
        }
      }
      break;

    default:
      throw new TypeError(
        `Unexpected request from parent process: ${request[0]}`,
      );
  }
};
process.on('message', messageListener);

function reportSuccess(result: unknown) {
  if (!process || !process.send) {
    throw new Error('Child can only be used on a forked process');
  }

  try {
    process.send([PARENT_MESSAGE_OK, result]);
  } catch (error) {
    if (
      isError(error) &&
      // if .send is a function, it's a serialization issue
      !error.message.includes('.send is not a function')
    ) {
      // Apply specific serialization only in error cases
      // to avoid affecting performance in regular cases.
      process.send([PARENT_MESSAGE_OK, packMessage(result)]);
    } else {
      throw error;
    }
  }
}

View on GitHub (pinned to f49721c78e)

Solutions

  1. 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.

When it happens

Trigger: Thrown at packages/jest-worker/src/workers/processChild.ts:98 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03). Data as JSON: /data/errors/9b642282a7077144.json. Report an issue: GitHub.