-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
Description
Hello,
This is half feature request / half bug report, depends on how you read it :D
I noticed evaluate() do not have a timeout and this can be problematic when executing on a busy thread that will never let go.
# http://localhost:3000/page-crash.html
<!DOCTYPE html>
<html>
<head> </head>
<body>
<script>
txt = "a";
while (1) {
txt = txt += "a";
}
</script>
</body>
</html>const playwright = require('playwright');
(async () => {
console.log('launching');
const browser = await playwright.chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
page.on('crash', () => {
console.log('Page crashed');
});
console.log('before goto');
try {
res = await page.goto('http://localhost:3000/page-crash.html', {
waitUntil: "domcontentloaded",
timeout: 2000,
});
} catch (e) {
// ignore timeout error
}
console.log('after goto');
await page.evaluate(() => {
console.log('hello');
});
console.log('after evaluate');
await browser.close();
console.log('close');
})()Will Display
~ node index.js
launching
before goto
after goto
# wait 1-2minutes
Page crashed
# nothing else until SIGINTPossible Resolutions
- Add a
timeouttoevaluateso that it at least throw a timeout error - Evaluate could be stopped by page crash
- Prevent page from consuming all the memory
Reactions are currently unavailable