Wait for the thing you are about to read instead of sleeping for a number of seconds. In Puppeteer that means page.waitForSelector for an element or page.waitForFunction for any condition the page can answer, each with a timeout. We learned it on our own detector runner, where three rows slept for a figure taken from one timing and kept reporting broken pages that were fine.

Three rows that were measuring the clock

Mosaic's detection suite opens 49 public fingerprint and bot detectors in a profile's real browser and reads each verdict off the page. For a long time a row could say only settleMs: open the page, sleep this long, then read. Three rows had their figure set from a single load:

pixelscan       20s, measured once at 8s     live it takes 26-34s
amiunique       32s, measured once at 30s    its bundles land at
                                             31.7s on one load and
                                             under 10s on the next
recaptcha-v3    35s, already raised from 20s the score arrives in 3s
                                             or never

AmIUnique is the clearest case. Its attribute table is built by four Nuxt bundles, and the page's own resource timings put them at 31.7s, 31.7s and 32.1s on one load and under ten seconds on the next. A 32-second sleep landed on either side of the same site by chance. When it landed early, the suite reported "neither the uniqueness headline nor the attribute table rendered", about a page that renders both.

Pixelscan gave fail, unread, unread across three fresh profiles, which looked like a regression in the profiles and was a 20-second sleep on a scan that takes 26 to 34.

Test a profile the way a site would, before a site doesIn Mosaic: Leak tests and detectors. A leak test and 49 public detectors, read for you. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

How it works: Leak tests and detectors

Wait for the element's value, not a sleep

Each row now declares a ready condition, a JavaScript expression the runner evaluates in the page once a second. The moment it is literally true, the run moves on. The old settleMs stays, but as a deadline: 90 seconds on all three rows.

The condition is not "the page has loaded" or "a results box exists". It is the fact the extractor is about to parse. For AmIUnique, that is either the headline ("You are unique among the…", or "not unique") or a row of the attribute table with a percentage in it. For reCAPTCHA v3, it is a score followed by a number between 0 and 1. Two readings of one fact, in two places, written the same way.

A 90-second deadline sounds slow, and it costs nothing on a fast load, because a page that is ready at four seconds is read at four seconds. The runner logs "ready after 4.0s of a 90s budget", so the record shows how much headroom each row had. A sleep has to be long enough for the slowest load and so charges every fast load for it. A poll charges only the loads that need it.

In Puppeteer the same idea is one call. page.waitForFunction "waits for the provided function, pageFunction, to return a truthy value when evaluated in the page's context", and takes polling and timeout options:

await page.goto('https://amiunique.org/fingerprint')
await page.waitForFunction(
  () => /You are\s*(?:not\s*)?unique among the/i
    .test(document.body.innerText),
  { polling: 1000, timeout: 90_000 }
)
// now read the headline, with the same pattern

waitForSelector is the right call when the thing you read is an element that appears once and is complete when it does. When the element appears empty and fills in later, a selector wait fires too early, and a function that checks the text inside it does not.

Two things a timeout should not do

We kept one rule from before: a ready that never fires is not turned into a failure by the timer. When the deadline passes, the runner reads the page anyway and lets the extractor say what is missing, in its own words. A timeout raised by the waiting code would replace "the scan had not finished" with "we gave up", which is a fact about our timer presented as one about their site.

And when it does time out, it says where the tab was. On the first run with the new waits, a click-started test on the EFF's Cover Your Tracks timed out and printed the tab is at https://firstpartysimulator.org/kcarter?try2=true (loading, visible, 0 chars). The test had navigated to its own tracker simulator mid-run and that host was serving nothing. "The test was still running" had been hiding a stalled third-party navigation for as long as the row existed. The whole chain is in what firstpartysimulator.org is.

The condition has to read a value, not a word

The first ready we wrote for that click matched /bits? of identifying information/ with no number in it. It fired at 42 seconds on the results page's own "How to read your report" section, text the page draws before any measurement lands. Requiring a number before "bits" fixed it, and that is the pattern the extractor already used.

A detector's labels are full of the words you are looking for in sentences that mean the opposite, so the condition should match the verdict's shape (a number, a score, a named state) and not a phrase that might appear in an explanation.

When waiting longer is the wrong repair

reCAPTCHA v3 had already had its sleep raised once, from 20 to 35 seconds, and a full run still read "no score in the expected 0.0-1.0 range" while a stock browser in the same session scored 0.9. With the clock out of the picture, the row still failed about one load in three. Google's demo page loads two scripts, api.js and enterprise.js, both define window.grecaptcha, and the Enterprise one puts execute a level down. Whichever loaded last won:

pass    api.js 180ms   enterprise.js 421ms
fail    api.js 156ms   enterprise.js  97ms

No sleep length fixes a race between two scripts. A comment above the old 35-second figure had even said it was a guess. Raising it was the wrong repair twice, and polling for the value is what made the real fault visible, because a wait that cannot be the cause any more leaves only the real cause standing.

If a row in your own suite only passes with a longer sleep, ask whether a stock browser on the same machine passes it at all before you change anything. That is the control that settles "is this ours". The rows above, with their deadlines and verdicts, are on detection tests.

Sources

  1. Puppeteer: Page.waitForFunction() method, read November 3, 2026