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

TimeoutError: waiting for target failed: timeout 30000ms exceeded #110

Open
flyfhj opened this issue Jun 16, 2023 · 7 comments
Open

TimeoutError: waiting for target failed: timeout 30000ms exceeded #110

flyfhj opened this issue Jun 16, 2023 · 7 comments

Comments

@flyfhj
Copy link

flyfhj commented Jun 16, 2023

Hello, I am running the following script on a linux OS:

const { launch, getStream } = require("puppeteer-stream");
const fs = require("fs");
const file = fs.createWriteStream(__dirname + "/test.webm");
async function test() {
	const browser = await launch({
		args: ['--no-sandbox'],
		allowIncognito: true,
		executablePath:'/web/download/node_modules/puppeteer/.local-chromium/linux-1056772/chrome-linux/chrome',
		headless: false,
		defaultViewport: {
			width: 1280,
			height: 1024
		},
		ignoreDefaultArgs: ["--disable-extensions", "--mute-audio"]
	});
	
	const page = await browser.newPage();
	await page.goto("https://www.bilibili.com/video/BV1kL411h7D5/");
	console.log("beginning......");
	const stream = await getStream(page, { audio: true, video: true });
	console.log("recording......");
	stream.pipe(file);
}
test();

But it always throws the following exception: timeout 30000ms exceeded

In order to be able to locate the problem, I added a log to the waitForTarget method in node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js

CODE:

 async waitForTarget(predicate, options = {}) {
 ...
 try {
     this.targets().forEach(check);
     if (!timeout) {
         return await targetPromise;
     }
     return await (0, util_js_1.waitWithTimeout)(targetPromise, 'target', timeout);
 }
 ...
 async function check(target) {
     console.log("<======check======>" + target.type() + ":" + target.url());
     if ((await predicate(target)) && !targetPromise.resolved()) {
         targetPromise.resolve(target);
     }
 }

The exception information is as follows:

<======check======>browser:
<======check======>page:about:blank
beginning......
<======check======>browser:
<======check======>page:about:blank
<======check======>service_worker:chrome-extension://jjndjgheafjngoipoacpjgeicjeomjli/background.js
<======check======>page:about:blank
<======check======>service_worker:chrome-extension://jjndjgheafjngoipoacpjgeicjeomjli/background.js
<======check======>service_worker:chrome-extension://jjndjgheafjngoipoacpjgeicjeomjli/background.js
/web/download/node_modules/puppeteer-core/lib/cjs/puppeteer/common/util.js:292
    const timeoutError = new Errors_js_1.TimeoutError(`waiting for ${taskName} failed: timeout ${timeout}ms exceeded`);
                         ^
TimeoutError: waiting for target failed: timeout 30000ms exceeded
    at waitWithTimeout (/web/download/node_modules/puppeteer-core/lib/cjs/puppeteer/common/util.js:292:26)
    at CDPBrowser.waitForTarget (/web/download/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js:342:56)
    at /web/download/node_modules/puppeteer-stream/dist/PuppeteerStream.js:107:47
    at Generator.next (<anonymous>)
    at /web/download/node_modules/puppeteer-stream/dist/PuppeteerStream.js:31:71
    at new Promise (<anonymous>)
    at __awaiter (/web/download/node_modules/puppeteer-stream/dist/PuppeteerStream.js:27:12)
    at getExtensionPage (/web/download/node_modules/puppeteer-stream/dist/PuppeteerStream.js:106:12)
    at /web/download/node_modules/puppeteer-stream/dist/PuppeteerStream.js:132:33
    at Generator.next (<anonymous>)

Version:

node:v16.14.0
npm:8.3.1
os:Linux version 3.10.0-1160.66.1.el7.x86_64
puppeteer:19.2.2
puppeteer-stream:3.0.3
chrome:linux-1056772

Hope to get your help,Thanks!

@nivhsay
Copy link
Contributor

nivhsay commented Jun 16, 2023

Try giving the headless argument to your chrome/chromium.
Usually --headless=new on newer versions.

@flyfhj
Copy link
Author

flyfhj commented Jun 19, 2023

Try giving the headless argument to your chrome/chromium. Usually --headless=new on newer versions.

Hi,I use the following parameters:

await launch({
   ...
   headless:'new',
   ...

But it still throws the same error.

@nivhsay
Copy link
Contributor

nivhsay commented Jun 19, 2023

The puppeteer-stream code overrides the headless launch option here

I believe the chrome extension needs the browser to launch with a "GUI" it to record the page.
So, setting it on the args works as it uses a virtual GUI with the Ozone platform, and this is not overridden by puppeteer-stream.

await launch({
   ...
  args: [
     ...
      '--headless=new',
     ...
    ],
   ...

@pantajoe
Copy link

I have the same problem and also receive the error TimeoutError: waiting for target failed on browser startup. @flyfhj Did you manage to solve that issue? @SamuelScheit Any insights into what's causing the issue?

@jcuna
Copy link

jcuna commented Oct 11, 2023

Having the same issue. Any updates?

@Takeno
Copy link
Contributor

Takeno commented Oct 14, 2023

Having the same issue. Any updates?
@jcuna

I am able to run it headless with this configuration:

  const browser = await launch({
    executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    defaultViewport: {
      width: 1920,
      height: 1080,
    },
    args: [
      '--no-sandbox',
      '--headless=new',
    ],
  });

@72L
Copy link

72L commented Sep 23, 2024

I'm getting the same error. I don't need it to be headless, so I ran it in headful. The page loads successfully, but nothing else happens and the timeout error occurs.

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

No branches or pull requests

6 participants