question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

page.setExtraHTTPHeaders cause 'ERR_INVALID_ARGUMENT' error

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.20.0
  • Platform / OS version: mac OS
  • URLs (if applicable):
  • Node.js version: v11.11.0

What steps will reproduce the problem?

const puppeteer = require('puppeteer');
(async () => {
    const browser = await puppeteer.launch({
        headless: false,
        ignoreHTTPSErrors: true,
        ignoreDefaultArgs: ["--enable-automation"],
        args: [
            '–no-sandbox',
        ]
    });
    const page = await browser.newPage();
    await page.setExtraHTTPHeaders(
        {'proxy-authorization': 'test'}
    );
    await page.goto('http://example.com/');
    await page.waitFor(10000);
    await browser.close();
})();

What is the expected result? go to the url success

What happens instead?

(node:86672) UnhandledPromiseRejectionWarning: Error: net::ERR_INVALID_ARGUMENT at http://example.com/
    at navigate (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/FrameManager.js:120:37)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
  -- ASYNC --
    at Frame.<anonymous> (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.goto (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/Page.js:674:49)
    at Page.<anonymous> (/Users/andrew/Documents/otherProject/vs/demo/node_modules/puppeteer/lib/helper.js:112:23)
    at /Users/andrew/Documents/otherProject/vs/demo/demo.js:16:16
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

But, if I replace header proxy-authorization to proxyauthorization, it’s fine. So,it seems that it’s not allowed containing ‘-’ in header, is this corrent? Or is it an issue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:16

github_iconTop GitHub Comments

19reactions
agarzolacommented, Feb 19, 2020

We’re getting the same ERR_INVALID_ARGUMENT error when setting a Host header via page.setExtraHTTPHeaders() and loading http://localhost/path/to/tested/page. When I curl it, I get the response I expect:

curl -H "Host: [REDACTED]" http://localhost/path/to/tested/page

Using v2.0.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve Puppeteer Chrome Error ... - Christian Fei
The main issue was that I tried to authenticate to the proxy with setExtraHTTPHeaders , like this: await page.setExtraHTTPHeaders({
Read more >
Developers - page.setExtraHTTPHeaders cause ...
page.setExtraHTTPHeaders cause 'ERR_INVALID_ARGUMENT' error. ... Coming soon: A brand new website interface for an even better experience!
Read more >
node.js - Puppeteer not loading page - NodeJs - Stack Overflow
It seems that page.authenticate is not working for me either,instead you can use page.setExtraHTTPHeaders. async function run() { const ...
Read more >
How to solve Puppeteer Chrome Error ... - diff.blog
The main issue was that I tried to authenticate to the proxy with setExtraHTTPHeaders, like this: await page.setExtraHTTPHeaders({ 'Proxy- ...
Read more >
How to use setExtraHTTPHeaders function in Page - Tabnine
logger.info('set headers to puppeteer page', this.headers); await page.setExtraHTTPHeaders(this.headers);
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found