{"id":"5c559108e735b760","repo":"jestjs/jest","slug":"workerpath-must-be-absolute-got-workerpath","errorCode":null,"errorMessage":"'workerPath' must be absolute, got '${workerPath}'","messagePattern":"'workerPath' must be absolute, got '(.+?)'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-worker/src/index.ts","lineNumber":100,"sourceCode":" */\nexport class Worker {\n  private _ending: boolean;\n  private readonly _farm: Farm;\n  private readonly _options: WorkerFarmOptions;\n  private readonly _workerPool: WorkerPoolInterface;\n\n  constructor(workerPath: string | URL, options?: WorkerFarmOptions) {\n    this._options = {...options};\n    this._ending = false;\n\n    if (typeof workerPath !== 'string') {\n      workerPath = workerPath.href;\n    }\n\n    if (workerPath.startsWith('file:')) {\n      workerPath = fileURLToPath(workerPath);\n    } else if (!isAbsolute(workerPath)) {\n      throw new Error(`'workerPath' must be absolute, got '${workerPath}'`);\n    }\n\n    const workerPoolOptions: WorkerPoolOptions = {\n      enableWorkerThreads: this._options.enableWorkerThreads ?? false,\n      forkOptions: this._options.forkOptions ?? {},\n      idleMemoryLimit: this._options.idleMemoryLimit,\n      maxRetries: this._options.maxRetries ?? 3,\n      numWorkers:\n        this._options.numWorkers ?? Math.max(availableParallelism() - 1, 1),\n      resourceLimits: this._options.resourceLimits ?? {},\n      setupArgs: this._options.setupArgs ?? [],\n      workerGracefulExitTimeout: this._options.workerGracefulExitTimeout,\n    };\n\n    if (this._options.WorkerPool) {\n      this._workerPool = new this._options.WorkerPool(\n        workerPath,\n        workerPoolOptions,","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-worker/src/index.ts#L82-L118","documentation":"Error \"'workerPath' must be absolute, got '${workerPath}'\" thrown in jestjs/jest.","triggerScenarios":"Thrown at packages/jest-worker/src/index.ts:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an absolute path to the worker file, e.g. use require.resolve('./myWorker') or path.resolve(__dirname, 'myWorker.js') instead of a relative path."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}