Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change puppeteer's waitForTimeout into direct setTimeout #1554

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

maciej-siola
Copy link
Contributor

Small fix to address #1553

In puppeteer waitForTimeout was implemented this way:

  /**
   * @deprecated Replace with `new Promise(r => setTimeout(r, milliseconds));`.
   *
   * Causes your script to wait for the given number of milliseconds.
   *
   * @remarks
   * It's generally recommended to not wait for a number of seconds, but instead
   * use {@link Frame.waitForSelector}, {@link Frame.waitForXPath} or
   * {@link Frame.waitForFunction} to wait for exactly the conditions you want.
   *
   * @example
   *
   * Wait for 1 second:
   *
   * ```ts
   * await frame.waitForTimeout(1000);
   * ```
   *
   * @param milliseconds - the number of milliseconds to wait.
   */
  async waitForTimeout(milliseconds: number): Promise<void> {
    return await new Promise(resolve => {
      setTimeout(resolve, milliseconds);
    });
  }

Therefore it should be sufficient to simply replace function calls with direct setTimeout.

Copy link
Owner

@garris garris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@garris garris merged commit 008ffc2 into garris:master Feb 27, 2024
1 check passed
@furai
Copy link

furai commented Feb 28, 2024

Thanks @maciej-siola & @garris for taking care of this! When can we expect a new release with the fix?

@garris
Copy link
Owner

garris commented Feb 28, 2024

6.3.21 was just pushed to NPM & Docker Hub. Thanks to everyone who helped get this patched!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants