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
[Bug]: Final status code changes when request intercept is TRUE #12183
Comments
This issue has an outdated Puppeteer version: |
I upgraded to 22.6.2 and still same issue. |
@OrKoN @Lightning00Blade any news about this? It's an urgent bug that need to be fixed in our project which is using puppeter. Thank you in advance. |
@kazanemed no updates here, we are happy to review a pull request if you find what is going wrong here. It is also possible that the issue is upstream in Chromium. |
I have tracked down the issue and it's that there is a bug in Chromium where there is no interception for an update from insecure to secure (header: For safekeeping Log Gist Test in Puppeteer it('redirect interception issue', async () => {
const {page} = await getTestState();
await page.setRequestInterception(true);
page.on('request', req => {
void req.continue();
});
const responses: HTTPResponse[] = [];
page.on('response', res => {
if (res.request().isNavigationRequest()) {
responses.push(res);
}
});
const response = await page.goto('https://bit.ly/1gqbFUR', {
waitUntil: ['networkidle0'],
});
console.log(responses.at(-1)?.status());
expect(response?.status()).toBe(200);
}); |
@Lightning00Blade the response received event has the 200 status but we do not detect that. It looks like we should be able to extra the right status even if some extra info events are missing? |
We have tracked down the issue to HttpsUpgrades. const browser = puppeteer.launch({
args: ["--disable-features=HttpsUpgrades"]
}) |
This works perfectly! Thank you @Lightning00Blade . |
Minimal, reproducible example
Error string
no error
Bug behavior
Background
When i set request interceptor ( even without logic inside ) and i do console log for the destination url status code of websites that has one of the following redirects statuses of 301, 302, 307 or 308 in the redirect chain, it gives me that the final status is either 301, 302, 307, 308 instead of the real destination page status code 200 as shown in my browser network tab for this website: https://bit.ly/1gqbFUR . But when i do remove Request Interceptor, i get the 200 status code.
Expectation
For this website as an example that has a 301 redirect : "https://bit.ly/1gqbFUR
", result of final url status code should be 200
Reality
I'm getting 301
Puppeteer configuration file (if used)
No response
Puppeteer version
21.10.0
Node version
18.17.0
Package manager
npm
Package manager version
9.6.7
Operating system
macOS
The text was updated successfully, but these errors were encountered: