Open georgils opened 5 months ago
I took a look at the network.rb source code and did some debugging which led me to the conclusion that the problem is me periodically calling page.network.clear(:traffic). I was doing it instinctively as if cleaning traffic in Developer Tools - I believe what DevTools/Network shows is just a log and deleting it won't affect the browser's behaviour. But maybe this is not the case with Ferrum - I seem to be deleting an Exchange object and that's why select(request.id)[-2]
returns nil...
**Describe the bug** My script crashes after a Ferrum thread throws an exception. First I get this:
#<Thread:0x0000027cd26b3900 C:/Users/User/.gem/ruby/3.2.0/gems/ferrum-0.15/lib/ferrum/utils/thread.rb:9 run> terminated with exception (report_on_exception is true): C:/Users/User/.gem/ruby/3.2.0/gems/ferrum-0.15/lib/ferrum/network.rb:376:in
block in subscribe_request_will_be_sent': undefined method `response=' for nil:NilClass (NoMethodError)followed by
undefined method
include?' for nil:NilClass (NoMethodError)from my code where traffic is from page.network.traffic.each { |traffic| .....}
Obviously my traffic.url is nil but somehow I don't believe this should be possible, I guess Chrome would not even create a request if the url is missing.
To Reproduce Sorry but can't imagine how to provide a meaningful context... I'll try to describe: 1. sending Chrome to a url. 2. filling a form which triggers a xhr 3. analyzing network traffic to obtain the specific xhr in question by filtering the array of Exchanges page.network.traffic on their url property.
Expected behavior
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context I don't know if this has something to do with the above (another nil object), but look at what I get in irb:
irb(main):062:0> browser = Ferrum::Browser.new(url: 'https://github.com/rubycdp/ferrum#frames') C:/Users/User/.gem/ruby/3.2.0/gems/ferrum-0.15/lib/ferrum/browser/process.rb:177:in
ws_url=': undefined method `host' for nil:NilClass (NoMethodError)