parcel-bundler/parcel · error · Error

Parcel is already profiling

Error message

Parcel is already profiling

What it means

`startProfiling` is a one-shot toggle guarded by the `isProfiling` flag. Parcel only allows one active profiling session per instance because the underlying worker farm profile is a single resource. Calling start while already running would corrupt the trace.

Source

Thrown at packages/core/core/src/Parcel.js:450

          this.#watchQueue.run();
        }
      },
      opts,
    );
    return {unsubscribe: () => sub.unsubscribe()};
  }

  // This is mainly for integration tests and it not public api!
  _getResolvedParcelOptions(): ParcelOptions {
    return nullthrows(
      this.#resolvedOptions,
      'Resolved options is null, please let parcel initialize before accessing this.',
    );
  }

  async startProfiling(): Promise<void> {
    if (this.isProfiling) {
      throw new Error('Parcel is already profiling');
    }

    logger.info({origin: '@parcel/core', message: 'Starting profiling...'});
    this.isProfiling = true;
    await this.#farm.startProfile();
  }

  stopProfiling(): Promise<void> {
    if (!this.isProfiling) {
      throw new Error('Parcel is not profiling');
    }

    logger.info({origin: '@parcel/core', message: 'Stopping profiling...'});
    this.isProfiling = false;
    return this.#farm.endProfile();
  }

  takeHeapSnapshot(): Promise<void> {

View on GitHub (pinned to 59484858a1)

Solutions

  1. Call `await parcel.stopProfiling()` before starting again.
  2. Guard with `if (!parcel.isProfiling)` before calling start.
  3. Restructure the caller to start/stop exactly once per profiled run.

Example fix

// before
await parcel.startProfiling();
await parcel.startProfiling();

// after
if (!parcel.isProfiling) await parcel.startProfiling();
Defensive patterns

Strategy: validation

Validate before calling

// Guard start against an in-flight session.
if (!parcel.isProfiling) await parcel.startProfiling();

Type guard

function canStartProfiling(p: {isProfiling: boolean}): boolean {
  return p.isProfiling === false;
}

Prevention

When it happens

Trigger: Calling `parcel.startProfiling()` twice without an intervening `stopProfiling()`.

Common situations: Test harnesses or scripts that start profiling on each build without stopping; retry logic that re-invokes start.

Related errors


AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13). Data as JSON: /api/errors/407dd449f5f5e592. Report an issue: GitHub.