{"record":{"id":"d192f74aafcb6900","repo":"parcel-bundler/parcel","slug":"parcel-is-not-profiling","errorCode":null,"errorMessage":"Parcel is not profiling","messagePattern":"Parcel is not profiling","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/Parcel.js","lineNumber":460,"sourceCode":"    return nullthrows(\n      this.#resolvedOptions,\n      'Resolved options is null, please let parcel initialize before accessing this.',\n    );\n  }\n\n  async startProfiling(): Promise<void> {\n    if (this.isProfiling) {\n      throw new Error('Parcel is already profiling');\n    }\n\n    logger.info({origin: '@parcel/core', message: 'Starting profiling...'});\n    this.isProfiling = true;\n    await this.#farm.startProfile();\n  }\n\n  stopProfiling(): Promise<void> {\n    if (!this.isProfiling) {\n      throw new Error('Parcel is not profiling');\n    }\n\n    logger.info({origin: '@parcel/core', message: 'Stopping profiling...'});\n    this.isProfiling = false;\n    return this.#farm.endProfile();\n  }\n\n  takeHeapSnapshot(): Promise<void> {\n    logger.info({origin: '@parcel/core', message: 'Taking heap snapshot...'});\n    return this.#farm.takeHeapSnapshot();\n  }\n\n  async unstable_transform(\n    options: ParcelTransformOptions,\n  ): Promise<Array<Asset>> {\n    if (!this.#initialized) {\n      await this._init();\n    }","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/Parcel.js#L442-L478","documentation":"`stopProfiling` is the counterpart to `startProfiling`. It requires `isProfiling` to be true because it must flush and collect the worker-farm profile that was started. Stopping with no active session has no profile to return and would yield undefined behavior.","triggerScenarios":"Calling `parcel.stopProfiling()` before any successful `startProfiling()`.","commonSituations":"Finally-blocks or teardown hooks that stop profiling defensively even when start failed or was skipped.","solutions":["Only call stop after a successful start.","Guard with `if (parcel.isProfiling)` before stopping.","Track the started state in your own flag if you cannot rely on `isProfiling`."],"exampleFix":"// before\nawait parcel.stopProfiling();\n\n// after\nif (parcel.isProfiling) await parcel.stopProfiling();","handlingStrategy":"validation","validationCode":"// Guard stop so it only runs when a session is active.\nif (parcel.isProfiling) await parcel.stopProfiling();","typeGuard":"function canStopProfiling(p: {isProfiling: boolean}): boolean {\n  return p.isProfiling === true;\n}","tryCatchPattern":"try {\n  await parcel.startProfiling();\n  // ... work\n} finally {\n  if (parcel.isProfiling) await parcel.stopProfiling();\n}","preventionTips":["Use try/finally with an `isProfiling` guard for teardown.","Don't call stop in error paths that never started."],"tags":["profiling","lifecycle"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}