microsoft/playwright · error · Error

Cannot clear timer: timer created with ${schedule}() but cle

Error message

Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()

What it means

Error "Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()" thrown in microsoft/playwright.

Source

Thrown at packages/injected/src/clock.ts:432

    const id = Number(timerId);

    if (Number.isNaN(id) || id < idCounterStart) {
      const handlerName = getClearHandler(type);
      new Error(`Clock: ${handlerName} was invoked to clear a native timer instead of one created by the clock library.`);
    }

    const timer = this._timers.get(id);
    if (timer) {
      if (
        timer.type === type ||
        (timer.type === 'Timeout' && type === 'Interval') ||
        (timer.type === 'Interval' && type === 'Timeout')
      ) {
        this._timers.delete(id);
      } else {
        const clear = getClearHandler(type);
        const schedule = getScheduleHandler(timer.type);
        throw new Error(
            `Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`,
        );
      }
    }
  }

  private _replayLogOnce() {
    if (!this._log.length)
      return;

    let lastLogTime = -1;
    let isPaused = false;

    for (const { type, time, param } of this._log) {
      if (!isPaused && lastLogTime !== -1)
        this._advanceNow(shiftTicks(this._now.ticks, time - lastLogTime));
      lastLogTime = time;

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/injected/src/clock.ts:432 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/f525520f699ed719. Report an issue: GitHub.