microsoft/playwright · error · Error

HAR recording has not been started

Error message

HAR recording has not been started

What it means

Error "HAR recording has not been started" thrown in microsoft/playwright.

Source

Thrown at packages/playwright-core/src/client/tracing.ts:124

        throw new Error('HAR recording has already been started');
      if (options.resourcesDir && path.endsWith('.zip'))
        throw new Error('resourcesDir option is not compatible with a .zip har file');
      const defaultContent = path.endsWith('.zip') ? 'attach' : 'embed';
      this._harId = await this._recordIntoHAR(path, null, {
        url: options.urlFilter,
        updateContent: options.content ?? defaultContent,
        updateMode: options.mode ?? 'full',
        resourcesDir: options.resourcesDir,
      });
    });
    return new DisposableStub(() => this.stopHar());
  }

  async stopHar() {
    await this._wrapApiCall(async () => {
      const harId = this._harId;
      if (!harId)
        throw new Error('HAR recording has not been started');
      this._harId = undefined;
      await this._exportHAR(harId);
    });
  }

  async _recordIntoHAR(har: string, page: Page | null, options: { url?: string | RegExp, updateContent?: 'attach' | 'embed' | 'omit', updateMode?: 'minimal' | 'full', resourcesDir?: string } = {}): Promise<string> {
    const isZip = har.endsWith('.zip');
    const { harId } = await this._channel.harStart({
      page: page?._channel,
      options: {
        content: options.updateContent ?? 'attach',
        urlGlob: isString(options.url) ? options.url : undefined,
        urlRegexSource: isRegExp(options.url) ? options.url.source : undefined,
        urlRegexFlags: isRegExp(options.url) ? options.url.flags : undefined,
        mode: options.updateMode ?? 'minimal',
        harPath: isZip ? undefined : har,
        resourcesDir: options.resourcesDir,
      },

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/playwright-core/src/client/tracing.ts:124 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/a1ad1ab0847f3aba. Report an issue: GitHub.