Open strunkie30 opened 7 months ago
This issue was not reproducible. Please check that your example runs locally and the following:
puppeteer
and puppeteer-core
.Ensure the error string is just the error message.
Bad:
Error: something went wrong
at Object.<anonymous> (/Users/username/repository/script.js:2:1)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Good: Error: something went wrong
.
Once the above checks are satisfied, please edit your issue with the changes and we will try to reproduce the bug again.
I am not able to reproduce:
import puppeteer from "puppeteer";
const browser = await puppeteer .connect({
browserWSEndpoint: process.env.BROWSER_WS_ENDPOINT,
protocolTimeout: 5000,
});
setInterval(() => {
console.log(browser.connected)
}, 1000);
starts printing close once the socket connection is closed. Could you provide more details about how exactly you close the socket?
I believe the primary concern is related to the tcp_keepalive_time
. If my assumption is correct, Puppeteer does not actively keep the socket alive. Consequently, when we verify if the browser is connected with browser.connected
, no message is sent to check the browser's health status.
I think this ticket is related by this: https://github.com/puppeteer/puppeteer/issues/1774
This is a very important issue / feature when you want to keep the browser running for a long time without interacting with it.
I see what you mean now. We rely on the close event from the client https://github.com/websockets/ws to update the connection status. It looks the client does not auto-detect broken connections.
We should probably implement a keepAlive option on the websocket transports and implement the ping/pong to keep the connection alive as described here https://github.com/websockets/ws?tab=readme-ov-file#how-to-detect-and-close-broken-connections
For now I'am requesting browser.version()
every minute and the browser has been running for hours. It would be great if an isAlive feature could be implemented! Thanks, @OrKoN, for your responses!
Minimal, reproducible example
When i connect to a puppeteer browser, the sockets are closed after a while. But the browser stays connected.
browser.connected === true
I can reproduce it when I'am closing the sockets of
process.env.BROWSER_WS_ENDPOINT
that puppeteer is still running and the browser is still connected until I run an action like:This scripts throws the error: