[Bug]: A paused clock still fires a timer the page sets while loading

Aperta
#43,869 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@microsoft-playwright-automation ci sta già lavorando.

Dal 3/11/2026.

  • #43873 di @microsoft-playwright-automation — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, typescript
Ambito
testing-qa

Direzione di ricerca

The clock logic lives in the injected clock code, where _replayLogOnce() sets _realTime = undefined in the paused branch while _currentRealTimeTimer is left armed; compare with _innerPause(), which disposes it. Start by running the repro test from the issue under the Playwright clock tests. Done when the timer no longer fires with the clock paused, and the test asserting fired is 0 passes in Chromium, Firefox and WebKit.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs-triage

After page.clock.pauseAt(), a timer that a newly loaded page sets during load fires once by itself, without runFor or fastForward.

Version: 1.63.0 in Chromium, Firefox and WebKit; also Chromium on 1.60.0, 1.64.1 and 1.65.0-alpha-2026-11-02 (after #43224). Linux, Node 24. Not seen on 1.48 or 1.56.

Repro:

import { test, expect } from "@playwright/test";

test("a paused clock does not fire a timer the page sets while loading", async ({ page }) => {
  await page.route("http://repro.test/", (route) =>
    route.fulfill({
      contentType: "text/html",
      body: "<script>window.fired = 0; setTimeout(() => window.fired++, 0);</script>",
    }),
  );
  await page.clock.install({ time: new Date("2024-01-15T12:00:00Z") });
  await page.clock.pauseAt(new Date("2024-01-15T12:00:10Z"));
  await page.goto("http://repro.test/");
  await page.waitForTimeout(500);
  expect(await page.evaluate(() => (window as any).fired)).toBe(0);
});

Expected: fired is 0. The clock is paused, so the timer waits for runFor.

Actual: fired is 1, 5 times out of 5 in each case above. Possibly related to #43214, but #43224 does not fix this one.

Cause: in a new document the injected clock starts running, and resume() arms the real-time timer. When _replayLogOnce() replays a log that ends paused, it sets _realTime = undefined but never disposes _currentRealTimeTimer. Up to 100 ms later that timer fires and runs _runTo(now), which fires every timer already due. Disposing the timer in the paused branch, as _innerPause() does, should fix it.

Lingua principale
TypeScript
Stelle
99.1k
Fork
6.8k
Merge medio
16h 3m
PR unite (30g)
315

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.