This topic was automatically generated from Slack. You can find the original thread here.
I’m having problems with Puppeteer since last week. Scripts that previously worked fine now fail every time. Error description:
Error
Navigation failed because browser has disconnected!
DETAILS
at null.LifecycleWatcher (file:///tmp/__pdg__/dist/code/1ae83d2cba0e8399278aaea31a3dec500dce78c73a17d42495d95ccf86582464/node_modules/.pnpm/puppeteer-core@19.8.0/node_modules/puppeteer-core/lib/esm/puppeteer/common/LifecycleWatcher.js:92:192)
at Frame.goto (file:///tmp/__pdg__/dist/code/1ae83d2cba0e8399278aaea31a3dec500dce78c73a17d42495d95ccf86582464/node_modules/.pnpm/puppeteer-core@19.8.0/node_modules/puppeteer-core/lib/esm/puppeteer/common/Frame.js:180:25)
at CDPPage.goto (file:///tmp/__pdg__/dist/code/1ae83d2cba0e8399278aaea31a3dec500dce78c73a17d42495d95ccf86582464/node_modules/.pnpm/puppeteer-core@19.8.0/node_modules/puppeteer-core/lib/esm/puppeteer/common/Page.js:436:91)
at Object.run (file:///tmp/__pdg__/dist/code/1ae83d2cba0e8399278aaea31a3dec500dce78c73a17d42495d95ccf86582464/component.mjs:7:16)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at null.executeComponent (/var/task/launch_worker.js:294:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:791:28)
I’m sorry to hear you’re experiencing issues with Puppeteer. The error message you’re encountering, “Navigation failed because browser has disconnected!”, typically indicates that the Puppeteer browser instance was closed or lost its connection before the navigation action (goto) could complete. This can happen for a variety of reasons, including changes in the Puppeteer library, environment issues, or specific changes in the code or the websites you’re trying to navigate. Given the details you’ve provided, it seems like there might have been an update or change in the environment that’s affecting the stability of the browser connection. Here are a few steps you can take to troubleshoot and potentially resolve this issue: 1. Verify Puppeteer Version: Ensure you’re using a compatible version of Puppeteer with the Pipedream environment. Pipedream supports the @pipedream/browsers package for browser automation, which includes Puppeteer. If there have been recent updates to Puppeteer, consider testing with a different version. 2. Review Recent Changes: If the scripts were working previously, review any recent changes to your code, the Pipedream environment, or the target website that might be causing the disconnection. 3. Error Handling: Implement error handling around the goto function to catch and log any errors. This might provide more insight into why the disconnection is occurring. 4. Increase Timeout: Sometimes, navigation failures can occur due to timeouts. Try increasing the timeout for the goto function to see if that helps maintain the connection. 5. Check for Browser Updates: Ensure that the underlying Chromium browser used by Puppeteer is up to date and compatible with the version of Puppeteer you’re using. 6. Simplify the Script: As a test, simplify your Puppeteer script to the bare minimum (e.g., open a browser, navigate to a simple website, then close the browser) to see if the issue persists. This can help isolate the problem. Here’s a simplified example of a Puppeteer script with error handling and increased timeout, using the @pipedream/browsers package: ``` import { puppeteer } from ‘@pipedream/browsers’; export default defineComponent({ async run({ steps, $ }) { try { const browser = await puppeteer.browser(); const page = await browser.newPage(); await page.goto(‘https://example.com’, { timeout: 60000 }); // Increase timeout to