page.waitForTimeout is gone from Puppeteer
page.waitForTimeout is not a functionShort answer
Puppeteer removed page.waitForTimeout in version 22, after deprecating it. For a plain pause use a Promise around setTimeout or the timers/promises module in Node.js. Better still, wait for the element or condition you need with waitForSelector or the locator API.
Fix it fast
1Find out which cause you have
Find every call so you can decide, one by one, whether it needs a pause or a real wait.
grep -rn "waitForTimeout" src2Match what you see, then jump to its fix
What does the error look like?
page.waitForTimeout is not a function'waitForTimeout' is deprecated.
Cause 1 of 2
A fixed delay was written with the removed method
1Check
The removal commit deleted the method from Page and Frame. It had been marked deprecated before, and the deprecation text gave the replacement.
npm ls puppeteer2Fix
Replace the call with a promise around setTimeout. The original ran on the Node.js side, so a Node.js timer is the closest match; the timers/promises module offers the same.
await new Promise((r) => setTimeout(r, 1000));
// or
import { setTimeout as sleep } from "node:timers/promises";
await sleep(1000);3Verify
Run the script. The pause should last as long as before.
node scrape.jsConfirmed by github.com
Cause 2 of 2
The delay hides what the script is really waiting for
1Check
The maintainers discourage waiting for an arbitrary time and point to waiting for the element.
grep -rn "waitForSelector" src2Fix
Wait for the element that proves the page is ready, or use the locator API, which waits for the element itself.
await page.waitForSelector("#results");
await page.locator("button.load-more").click();3Verify
Run the script on a slow connection and check that it still finds the data.
node scrape.jsConfirmed by github.com
How do I stop it coming back?
- Wait for selectors and locators, not for fixed times, so the script runs as fast as the page allows.
- Pin the Puppeteer version in package.json and read the release notes before you bump a major version.
- Run the type check in CI; a removed method then fails the build.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Back end
TypeScript cannot find '@angular/platform-browser' in an Angular project
Cannot find module '@angular/platform-browser' or its corresponding type declarations.
TS2307 means TypeScript could not turn the import into a file.
3 causes, each with a fixBack end
Angular build fails with TS2707 or "has no exported member" after installing a library
Module '"@angular/core"' has no exported member
These errors mean a library was compiled by a newer Angular than your app uses.
3 causes, each with a fixBack end
cdk synth says --app is required
--app is required either in command-line, in cdk.json or in ~/.cdk.json
The CDK CLI needs a command that runs your app and finds it in three places: the --app option, cdk.json in the project folder, or cdk.json in your home folder.
3 causes, each with a fixBack end
TypeScript cannot find module '@nestjs/core' or its type declarations
error TS2307: Cannot find module '@nestjs/common' or its corresponding type declarations.
TS2307 means TypeScript searched node_modules and found neither the package nor its types.
3 causes, each with a fixBack end
Mocha or Node cannot find ts-node/register
Error: Cannot find module 'ts-node/register'
Node resolves ts-node/register from your project's node_modules, so the package must be installed there, next to typescript.
2 causes, each with a fixBack end
TypeError: Class constructor cannot be invoked without 'new' in compiled TypeScript
TypeError: Class constructors cannot be invoked without 'new'
Node.js throws this when a native class is called like a plain function.
2 causes, each with a fix