request.continue() throws net::ERR_INVALID_ARGUMENT if change the url
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.17.0
- Platform / OS version: mac OS
- URLs (if applicable):
- Node.js version: 12.3.1
What steps will reproduce the problem?
const puppeteer = require('puppeteer')
puppeteer.launch().then(async browser => {
const page = await browser.newPage()
await page.setRequestInterception(true)
page.on('request', req => {
let url = req.url()
const headers = req.headers()
url = url.replace('example.dev', 'example.com')
headers.host = 'example.com'
return req.continue({ url, headers })
})
await page.goto('https://example.dev')
await browser.close()
})
What is the expected result? No error. v1.16.0 is OK. Only v1.17.0 will throw the error.
What happens instead?
(node:1543) UnhandledPromiseRejectionWarning: Error: net::ERR_INVALID_ARGUMENT at https://example.dev
at navigate (/Users/fenix/projects/puppeteer-prerender/node_modules/.registry.npmjs.org/puppeteer/1.17.0/node_modules/puppeteer/lib/FrameManager.js:121:37)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
-- ASYNC --
at Frame.<anonymous> (/Users/fenix/projects/puppeteer-prerender/node_modules/.registry.npmjs.org/puppeteer/1.17.0/node_modules/puppeteer/lib/helper.js:110:27)
at Page.goto (/Users/fenix/projects/puppeteer-prerender/node_modules/.registry.npmjs.org/puppeteer/1.17.0/node_modules/puppeteer/lib/Page.js:629:49)
at Page.<anonymous> (/Users/fenix/projects/puppeteer-prerender/node_modules/.registry.npmjs.org/puppeteer/1.17.0/node_modules/puppeteer/lib/helper.js:111:23)
at /Users/fenix/projects/puppeteer-prerender/examples/puppeteer-issue.js:17:14
at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:1543) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1543) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Node Puppeteer, page.on( "request" ) throw a ... - Stack Overflow
Adding a return statement solved the issue on my end. page.on( 'request', ( request ) => { if ([ 'image', 'stylesheet', 'font', 'script'...
Read more >HTTPRequest.continue() method - Puppeteer
Continues request with optional request overrides. ... setRequestInterception(). Exception is immediately thrown if the request interception is not enabled.
Read more >Intercepting requests | Checkly
Request interception. Request interception enables us to observe which requests and responses are being exchanged as part of our script's execution. For example ......
Read more >puppeteer.Page.on JavaScript and Node.js code examples
(async () => { const browser = await puppeteer.launch() const page ... setRequestInterception(true) page.on('request', async (request) => { if (request.
Read more >utils.puppeteer - Apify SDK
In addition to that any of the handlers may modify the request object (method, postData, headers) by passing its overrides to request.continue() ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like Chromium now prohibits setting “host” header.
So if you simply remove overwriting the “host” header - things will work. Why do you want to overwrite “host” header?
In android webview ,I solved it.