Navigation Menu

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

The default page chromium opens is invalid #5737

Closed
evandrocoan opened this issue Apr 25, 2020 · 7 comments
Closed

The default page chromium opens is invalid #5737

evandrocoan opened this issue Apr 25, 2020 · 7 comments

Comments

@evandrocoan
Copy link

evandrocoan commented Apr 25, 2020

These errors only happen because of the argument "" passed to chromium and if chrome is launched with headless: true. If headless: false or we do not pass "" as an argument to chroming, then, no errors happen when using the default page.

When I begin testings, I was directly trying to use the default page (let [page] = await browser.pages()) instead of creating a new page with let page = await browser.newPage().

Trying to use the default page, caused awkward errors in the first tests trying to use the default page: TimeoutError: Timed out after 30000 ms while trying to connect to Chrome, Protocol error (Runtime.callFunctionOn): Execution context was destroyed, Error details for UnhandledPromiseRejectionWarning (#1591, #4253, #4651). These tests would hang forever (https://github.com/evandroforks/anki/runs/610551447?check_suite_focus=true#step:27:1649). The problem was fixed after creating a new page let page = await browser.newPage() instead of trying to use the default page let [page] = await browser.pages().

If I try to print the page contents with document.body.innerHTML nothing is output. But if I do a await page.reload() right before, then, the page contents are printed. These problems only happen with headless: true.

Perhaps add to the documentation to never use the default page? Or warn about the problems an empty string ("") can cause when passed as an argument to chromium?

I was accidentally passing "" as an argument to chromium because I was reading arguments from an environment variable in the wrong way:

let PUPPETEER_CHROME_ARGS = process.env.PUPPETEER_CHROME_ARGS || "";
let chrome_args = []
chrome_args.push(...PUPPETEER_CHROME_ARGS.split(' '));

This way I ended up adding an empty arg "" when the environment variable was undefined. The correct way would be this:

let PUPPETEER_CHROME_ARGS = process.env.PUPPETEER_CHROME_ARGS;
if(PUPPETEER_CHROME_ARGS) {
    PUPPETEER_CHROME_ARGS = PUPPETEER_CHROME_ARGS.trim();
    if(PUPPETEER_CHROME_ARGS.length > 0) {
        chrome_args.push(...PUPPETEER_CHROME_ARGS.split(' '));
    }
}

What steps will reproduce the problem?

Just run: node file.js

const puppeteer = require('puppeteer');

(async () => {
    let browser;
    let page;
    let address = process.env.SERVER_ADDRESS;

    console.log("beforeAll");
    browser = await puppeteer.launch({
        dumpio: true,
        headless: true,
        args: [""],
    });

    let [default_page] = await browser.pages();
    page = default_page;
    // page = await browser.newPage();

    page.on('console', async msg => console[msg._type](
        ...await Promise.all(msg.args().map(arg => arg.jsonValue()))
    ));

    // await page.reload();
    let contents = await default_page.evaluate(async () => String(document.body.innerHTML));
    console.log('contents', contents);
    browser.close()
})();

Running it on Windows results in:

2020-04-23T01:12:12.0950547Z [0423/011212.084:INFO:CONSOLE(1)] "Uncaught ReferenceError: start is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (1)
2020-04-23T01:12:12.0962301Z [0423/011212.084:INFO:CONSOLE(2)] "Uncaught ReferenceError: onHasParentDirectory is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (2)
2020-04-23T01:12:12.0963019Z [0423/011212.084:INFO:CONSOLE(3)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (3)
2020-04-23T01:12:12.0963641Z [0423/011212.084:INFO:CONSOLE(4)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (4)
2020-04-23T01:12:12.1649199Z [0423/011212.163:INFO:CONSOLE(5)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (5)
2020-04-23T01:12:12.1650694Z [0423/011212.163:INFO:CONSOLE(6)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (6)
2020-04-23T01:12:12.1662711Z [0423/011212.163:INFO:CONSOLE(7)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (7)
2020-04-23T01:12:12.1666218Z [0423/011212.163:INFO:CONSOLE(8)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (8)
2020-04-23T01:12:12.1668090Z [0423/011212.163:INFO:CONSOLE(9)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (9)
2020-04-23T01:12:12.1668876Z [0423/011212.163:INFO:CONSOLE(10)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (10)
2020-04-23T01:12:12.1669573Z [0423/011212.163:INFO:CONSOLE(11)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (11)
2020-04-23T01:12:12.1670282Z [0423/011212.163:INFO:CONSOLE(12)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (12)
2020-04-23T01:12:12.1670968Z [0423/011212.163:INFO:CONSOLE(13)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (13)
2020-04-23T01:12:12.1671655Z [0423/011212.163:INFO:CONSOLE(14)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (14)
2020-04-23T01:12:12.1672326Z [0423/011212.163:INFO:CONSOLE(15)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (15)
2020-04-23T01:12:12.1673017Z [0423/011212.163:INFO:CONSOLE(16)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (16)
2020-04-23T01:12:12.1673683Z [0423/011212.163:INFO:CONSOLE(17)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (17)
2020-04-23T01:12:12.1674367Z [0423/011212.163:INFO:CONSOLE(18)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (18)
2020-04-23T01:12:12.1675824Z [0423/011212.163:INFO:CONSOLE(19)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (19)
2020-04-23T01:12:12.1678629Z [0423/011212.163:INFO:CONSOLE(20)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (20)
2020-04-23T01:12:12.1679470Z [0423/011212.163:INFO:CONSOLE(21)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (21)
2020-04-23T01:12:12.1680160Z [0423/011212.163:INFO:CONSOLE(22)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (22)
2020-04-23T01:12:12.1680854Z [0423/011212.163:INFO:CONSOLE(23)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (23)
2020-04-23T01:12:12.1681530Z [0423/011212.163:INFO:CONSOLE(24)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (24)
2020-04-23T01:12:12.1683081Z [0423/011212.163:INFO:CONSOLE(25)] "Uncaught ReferenceError: addRow is not defined", source: file:///D:/node_modules/puppeteer/.local-chromium/win64-737027/chrome-win/ (25)

Running it on Linux results in:

0425/022342.172244:ERROR:command_buffer_proxy_impl.cc(125)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
[0425/022342.175223:INFO:CONSOLE(1)] "Uncaught ReferenceError: start is not defined", source: file:/// (1)
[0425/022342.176847:INFO:CONSOLE(2)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (2)
[0425/022342.177838:INFO:CONSOLE(3)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (3)
[0425/022342.178803:INFO:CONSOLE(4)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (4)
[0425/022342.179926:INFO:CONSOLE(5)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (5)
[0425/022342.180478:INFO:CONSOLE(6)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (6)
[0425/022342.181449:INFO:CONSOLE(7)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (7)
[0425/022342.182746:INFO:CONSOLE(8)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (8)
[0425/022342.183603:INFO:CONSOLE(9)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (9)
[0425/022342.184681:INFO:CONSOLE(10)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (10)
[0425/022342.186450:INFO:CONSOLE(11)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (11)
[0425/022342.186604:INFO:CONSOLE(12)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (12)
[0425/022342.186677:INFO:CONSOLE(13)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (13)
[0425/022342.187918:INFO:CONSOLE(14)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (14)
[0425/022342.191192:INFO:CONSOLE(15)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (15)
[0425/022342.191289:INFO:CONSOLE(16)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (16)
[0425/022342.191367:INFO:CONSOLE(17)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (17)
[0425/022342.191431:INFO:CONSOLE(18)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (18)
[0425/022342.191563:INFO:CONSOLE(19)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (19)
[0425/022342.191660:INFO:CONSOLE(20)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (20)
[0425/022342.191728:INFO:CONSOLE(21)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (21)
[0425/022342.193194:INFO:CONSOLE(22)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (22)
[0425/022342.193808:INFO:CONSOLE(23)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (23)
[0425/022342.194353:INFO:CONSOLE(24)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (24)
[0425/022342.194843:INFO:CONSOLE(25)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (25)
[0425/022342.195553:INFO:CONSOLE(26)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (26)
[0425/022342.196168:INFO:CONSOLE(27)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (27)
[0425/022342.196328:INFO:CONSOLE(28)] "Uncaught ReferenceError: addRow is not defined", source: file:/// (28)

Tell us about your environment:

After tracking down these prints, I found they located on the chromium directory_listing.cc: https://chromium.googlesource.com/chromium/src/net/+/master/base/directory_listing.cc, https://chromium.googlesource.com/chromium/src/gpu/+/master/ipc/client/command_buffer_proxy_impl.cc, https://bugs.chromium.org/p/chromium/issues/detail?id=737678, https://gist.github.com/morganrallen/f955cc0312ae2cdbe9a5, #1610 - HTML render with headless chrome + GPU hangs, #1665 - async function inside evaluate fails.

@obsd
Copy link

obsd commented Oct 15, 2020

happens to me as well on Linux Centos 7 with chrome version Chromium 85.0.4183.121 Fedora Project

@stale
Copy link

stale bot commented Jun 25, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 25, 2022
@teoring
Copy link

teoring commented Jun 28, 2022

This issue likely causes this in my application:

[2022-06-28T13:10:38.444] [ERROR] crawlson - Unexpected error:  Protocol error (Target.closeTarget): Target closed. ProtocolError: Protocol error (Target.closeTarget): Target closed.
    at /home/kk/Development/utilities_and_research/crawlson/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:97:24
    at new Promise (<anonymous>)
    at Connection.send (/home/kkk/Development/utilities_and_research/crawlson/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:93:16)
    at Page.close (/home/kkk/Development/utilities_and_research/crawlson/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1885:30)

When I change

         let [default_page] = await browser.pages();
         let page = default_page;

To

            const page = await browser.newPage();

Issue goes away.

@stale stale bot removed unconfirmed labels Jun 28, 2022
@stale
Copy link

stale bot commented Aug 30, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Aug 30, 2022
@evandrocoan
Copy link
Author

#botsdontlikebugs

@stale stale bot removed the unconfirmed label Aug 31, 2022
@OrKoN
Copy link
Collaborator

OrKoN commented Sep 5, 2022

As for the original issue: providing the "" as an argument causes Chromium to treat as an URL and you probably should not do it (looks like a issue to be reported upstream at crbug.com). I think other commenters are likely to have a different issue.

@OrKoN
Copy link
Collaborator

OrKoN commented Jan 5, 2024

@OrKoN OrKoN closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants