-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Exchange#finished returns true before response body is ready #197
Comments
Great research! I'm open to all options. Everything you said sounds correct, we just need to take only one direction. As for me I usually start to play with code and then after a few implementations see a solution, so I cannot tell right now what's better or best. Are you going to work on a PR? |
If you don't know of a reason not to, I'll change the |
Ok! Sounds right |
Grrr ... I tried to use it on something else and got Ferrum::BrowserError: No resource with given identifier found ... AND when I tried to use inspect, I found the resource was loaded from cache, although it's not mentioned anywhere in that response object (all from*Cache are false). |
@ttilberg I am also facing this issue, do you still plan to open a PR on your suggestions (which look good !) ? Thanks ! |
I was having a hard time figuring out how to create the tests to set up the delayed payload, and I kind of got discouraged and tabled it. Please feel free! |
Hello, I'm trying to intercept the response body of an XHR request. After looking through the spec files, I saw that Ferrum keeps track of all of the network traffic, which is convenient for this case. (I tried using on('Network.responseReceived') hooks, but couldn't work it out.)
While waiting for the correct
Exchange
to befinished?
I kept running intoFerrum::BrowserError: No data found for resource with given identifier
. Example code:After some research, I've learned that instead you should wait for
Network.loadingFinished
before trying to get the response body.I wanted to highlight a few notes in Ferrum's API as I wonder if
Exchange#finished?
should wait for that event, or if theResponse
object c/should be more clever. (Or both).Note how the exchange is
finished?
when it has aresponse
object. But also notice that this response attribute is assigned in theNetwork.responseReceived
hook, not theNetwork.loadingFinished
hook. There is, however, a property that gets set atNetwork.loadingFinished
,body_size
, so I tried keying off that:With this change, this code no longer raises the noted exception, though the API is being used in a strange way.
Exchange#finished?
should account for the response being fully loaded and prepared to query. Maybe this isn't sensible due to existing usages for#finished?
and things like streamed content. So, worst case, maybe something new?Response#finished?
orloaded?
orready?
response.body
should wait for an attribute to signal that the response is finished loading, leveraging the standard Ferrum timeouts, similar to how other calls on the browser block until CDP has reported it's ready.The text was updated successfully, but these errors were encountered: