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

fix: correctly resolve OOPIF response bodies #13311

Merged
merged 5 commits into from
Nov 21, 2024

Conversation

ezg27
Copy link
Contributor

@ezg27 ezg27 commented Nov 19, 2024

What kind of change does this PR introduce?

Bugfix

Did you add tests for your changes?

Yes

If relevant, did you update the documentation?

Summary

Fix for #13307. I've raised it as a draft initially as there's a potential edge case that this may need to account for in #maybeReassignOOPIFRequestClient - namely, if we end up with different sessions for a document request on the main frame (top-level page). Is this something you're aware can happen? If so, what do you think would be the best way of making this info available for this check in NetworkManager, i.e. does the CDPSession that just received a Network.loadingFinished or Network.loadingFailed event belong to the 'main' target or not?

Does this PR introduce a breaking change?

No

Other information

@ezg27 ezg27 changed the title Fix/oopif response body fix: correctly resolve oopif response bodies Nov 19, 2024
@ezg27 ezg27 changed the title fix: correctly resolve oopif response bodies fix: correctly resolve OOPIF response bodies Nov 19, 2024
@OrKoN
Copy link
Collaborator

OrKoN commented Nov 20, 2024

Fix for #13307. I've raised it as a draft initially as there's a potential edge case that this may need to account for in #maybeReassignOOPIFRequestClient - namely, if we end up with different sessions for a document request on the main frame (top-level page). Is this something you're aware can happen? If so, what do you think would be the best way of making this info available for this check in NetworkManager, i.e. does the CDPSession that just received a Network.loadingFinished or Network.loadingFailed event belong to the 'main' target or not?

what do you mean by different sessions for a document request? The only thing that can happen is that the network manager gets a new client on pre-rendering activation but that is not associated with a network request so it should not have an effect on ongoing network activity (except that the client before the activation will get disconnected and its network data would not be available anymore). I think the solution in this PR for updating the client to the client that received the loading finished/failed events makes sense.

@ezg27
Copy link
Contributor Author

ezg27 commented Nov 20, 2024

Apologies I should have given a clearer example. With the OOPIF scenario, this new check works because the HTTPRequest instance for its navigation request is initialised with the client of the main target where its initial CDP events are fired, but then it’s Network.loadingFinished or Network.loadingFailed are fired on the OOPIF target, so this check can compare the clients in the #onLoadingFinished and #onLoadingFailed handlers and reassign clients if needed.

My question was is there a possible scenario where we’d receive a navigation request for the main target where its initial CDP events are fired on the main target client (and so it’s HTTPRequest instance is initialised with this client), but then it’s Network.loadingFinished or Network.loadingFailed events are fired on a different client, leading to this new check being true for the main target and its session being reassigned (e.g. if Puppeteer swaps out frame clients for the main target some reason)? If that’s not a possibility then all good :)

I can see there’s some failing tests in CI, i’ll try and take a look at those this evening.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 20, 2024

Got it, thanks for the explanation, so I do not think the scenario you describe can currently happen.

The failing tests seem to be for the WebDriver BiDi implementation that do not support getting the response bodies yet. Let's mark the test as FAIL in test/TestExpectations.json for "webDriverBiDi" on all platforms.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 20, 2024

you can run npm run format to fix all formatting/lint issues that could be automatically fixed (it includes also the formatting for the expectation files)

@ezg27
Copy link
Contributor Author

ezg27 commented Nov 20, 2024

Ahh ok thanks, have applied those changes now.

@OrKoN OrKoN force-pushed the fix/oopif-response-body branch from 9685437 to b2cc873 Compare November 20, 2024 21:33
@OrKoN OrKoN force-pushed the fix/oopif-response-body branch from b2cc873 to 3f014e2 Compare November 21, 2024 07:20
@OrKoN OrKoN marked this pull request as ready for review November 21, 2024 07:20
@OrKoN OrKoN added full-ci and removed full-ci labels Nov 21, 2024
@OrKoN OrKoN removed the full-ci label Nov 21, 2024
@OrKoN OrKoN enabled auto-merge (squash) November 21, 2024 08:21
@OrKoN OrKoN merged commit e837140 into puppeteer:main Nov 21, 2024
104 checks passed
@release-please release-please bot mentioned this pull request Nov 21, 2024
@release-please release-please bot mentioned this pull request Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants