
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
graceful-playwright
Advanced tools
Gracefully handle timeout and network error with auto retry.
auto retry when page.goto()
timeout or encountered ERR_NETWORK_CHANGED
auto restart page when page.goto()
crashed with /page crashed/i
error
helper method to auto retry when failed with The object has been collected to prevent unbounded heap growth
error
support restarting page from Browser
or BrowserContext
instance
support wrapping existing Page
instance
proxy frequently used methods
create Page
instance lazily (on-demand)
npm install graceful-playwright
You can install the package with yarn, pnpm or slnpm as well.
More usage examples see: example.ts and core.spec.ts
import { GracefulPage } from 'graceful-playwright'
let browser = await chromium.launch()
let page = new GracefulPage({ from: browser })
let lines: string[] = await page.autoRetryWhenFailed(async () => {
await page.goto('http://example.net')
return await page.evaluate(() =>
Array.from(document.querySelectorAll('a'), a => a.href),
)
})
console.log('lines:', lines)
await page.close()
await browser.close()
import { Browser, BrowserContext, Page, Response } from 'playwright'
export class GracefulPage {
constructor(
public options: {
from: Browser | BrowserContext
page?: Page | Promise<Page>
/**
* @default 5000 ms
*/
retryInterval?: number
/**
* @default error => console.error(error)
*/
onError?: (error: unknown) => void
},
)
fork(): GracefulPage
getPage(): Page | Promise<Page>
restart(options?: Parameters<Page['close']>[0]): Promise<Page>
/** @description optimized version of page.close() */
close: Page['close']
/** @description graceful version of page.goto() */
goto(
url: string,
/**
* @default { waitUtil: "domcontentloaded" }
*/
options?: Parameters<Page['goto']>[1],
): Promise<Response | null>
autoRetryWhenFailed<T>(f: () => T | Promise<T>): Promise<T>
/** @description proxy method to (await this.getPage())[method] */
evaluate: Page['evaluate']
waitForSelector: Page['waitForSelector']
fill: Page['fill']
click: Page['click']
content: Page['content']
title: Page['title']
innerHTML: Page['innerHTML']
innerText: Page['innerText']
}
This project is licensed with BSD-2-Clause
This is free, libre, and open-source software. It comes down to four essential freedoms [ref]:
FAQs
Gracefully handle timeout and network error with auto retry.
The npm package graceful-playwright receives a total of 13 weekly downloads. As such, graceful-playwright popularity was classified as not popular.
We found that graceful-playwright demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.