I'm using Ferrum 0.14 + Ruby 3.2.2 with Browserless. Browserless not only makes it simple to run Chrome headless but it also offers some extras like checking which sessions are active and what it's doing.
So, when I start it there are no sessions:
[1]pry(main)> JSON.parse(RestClient.get('http://chrome:3333/sessions'))=>[]I start Ferrum and can see that the session is now showing up:
[2]pry(main)> browser=Ferrum::Browser.new(url: 'http://chrome:3333')=>#<Ferrum::Browser:0x0000ffff7f309e70[3]pry(main)> JSON.parse(RestClient.get('http://chrome:3333/sessions'))=>[{"description"=>"","devtoolsFrontendUrl"=>"/devtools/inspector.html?ws=0.0.0.0:3333/devtools/page/A87609DAEBF35E0FF8AF4E0C4FD64D4D","id"=>"A87609DAEBF35E0FF8AF4E0C4FD64D4D","title"=>"about:blank","type"=>"page","url"=>"about:blank","webSocketDebuggerUrl"=>"ws://0.0.0.0:3333/devtools/page/A87609DAEBF35E0FF8AF4E0C4FD64D4D","port"=>"33131","browserId"=>"e2bb3742-d16a-4c94-931a-29336a8153cf","trackingId"=>nil,"browserWSEndpoint"=>"ws://0.0.0.0:3333/devtools/browser/e2bb3742-d16a-4c94-931a-29336a8153cf"}]But when i run browser.quit, it doesn't close the session, leaving it open forever:
[4]pry(main)> browser.quit=>nil[5]pry(main)> JSON.parse(RestClient.get('http://chrome:3333/sessions'))=>[{"description"=>"","devtoolsFrontendUrl"=>"/devtools/inspector.html?ws=0.0.0.0:3333/devtools/page/A87609DAEBF35E0FF8AF4E0C4FD64D4D","id"=>"A87609DAEBF35E0FF8AF4E0C4FD64D4D","title"=>"about:blank","type"=>"page","url"=>"about:blank","webSocketDebuggerUrl"=>"ws://0.0.0.0:3333/devtools/page/A87609DAEBF35E0FF8AF4E0C4FD64D4D","port"=>"33131","browserId"=>"e2bb3742-d16a-4c94-931a-29336a8153cf","trackingId"=>nil,"browserWSEndpoint"=>"ws://0.0.0.0:3333/devtools/browser/e2bb3742-d16a-4c94-931a-29336a8153cf"}]The session is only closed after I close the IRB console and terminate the process.
[6] pry(main)> exit 0
root@c31d1e2b8b58:/myapp# curl http://chrome:3333/sessions
[]
When using Ferrum in a long running process like Sidekiq/Puma, this results in thousands of sessions open since the process is never terminated.
I guess that it might also explain the issues with zombie processes previously reported ( #364 ).
Is browser.close the correct way of terminating the session or am I missing something?
I'm using Ferrum 0.14 + Ruby 3.2.2 with Browserless. Browserless not only makes it simple to run Chrome headless but it also offers some extras like checking which sessions are active and what it's doing.
So, when I start it there are no sessions:
I start Ferrum and can see that the session is now showing up:
But when i run browser.quit, it doesn't close the session, leaving it open forever:
The session is only closed after I close the IRB console and terminate the process.
When using Ferrum in a long running process like Sidekiq/Puma, this results in thousands of sessions open since the process is never terminated.
I guess that it might also explain the issues with zombie processes previously reported ( #364 ).
Is browser.close the correct way of terminating the session or am I missing something?