[BUG] Cannot remove header in `route.continue`
See original GitHub issueContext:
- Playwright Version: 1.20.1
- Operating System: Linux
- Node.js version: 17.8.0
- Browser: Chromium
Code Snippet
const playwright = require('playwright');
require('http').createServer((request, response) => {
response.end('');
}).listen(8888);
(async () => {
const browser = await playwright.chromium.launchPersistentContext('', {
headless: false,
});
const page = await browser.newPage();
await page.route('**/*', (route, request) => {
// Override headers
const headers = {
...request.headers(),
foo: 'bar', // set "foo" header
origin: undefined, // remove "origin" header
};
route.continue({headers});
});
await page.goto('http://localhost:8888/', { waitUntil: 'load' });
})();
Describe the bug
The example https://playwright.dev/docs/next/api/class-route#route-continue is broken.
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
route.continue: headers[7].value: expected string, got undefined
at RouteHandler.handler (/home/szm/Desktop/cache/bug6.js:21:18)
Node.js v17.8.0
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Can't Delete Header and Footer - Microsoft Community
I want to delete the header and footer from my Word document but it doesn't seem to want to leave. I click on...
Read more >Cannot remove headers after they are sent to the client - Stack ...
You get this error because you are calling res.send() multiple times: router.get('/hello', async function(req, res, next) { const allData ...
Read more >Sections / Headers and Footers in Microsoft Word
REMINDER: If you have multiple Sections in a document and a Section's header/footer is set for link to previous, that will continue not...
Read more >Adding custom headers to origin requests - Amazon CloudFront
Use an origin request policy that forwards all viewer headers to the origin. You cannot forward the Authorization header individually in an origin...
Read more >Exception Clause - Apache Camel
So the caller receives an Exchange with the payload Order ERROR and a orderid=failed in a header. Using Handled with Spring XML DSL....
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 Free
Top 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
Thanks for confirming. Setting to
undefined
should now delete headers. I looked at WebKit implementation and there is no simple way to make it remove/update origin header, I’ve filed a separate issue for that (https://github.com/microsoft/playwright/issues/13886) and will wait until there is more demand for this before implementing any suboptimal solutions.Thanks for the report! I repro’d locally.
Does using
delete
built-in before passing along the headers work for your use case?Regardless, we’ll either update the docs or make the doc example work!
Note from repro: The error is likely from our protocol type def: https://github.com/microsoft/playwright/blob/1471bb71776cf84223190e1552ee4e055db1547a/packages/playwright-core/src/protocol/protocol.yml#L2442