MENU

herokuのfree dynoでchromeを動かすとSelenium::WebDriver::Errorでクラッシュする

エラー

Selenium::WebDriver::Error::UnknownError: unknown error: session deleted because of page crash

リモートサーバー環境

herokuのfree dyno f:id:spreadthec0ntents:20210426065357p:plain メモリは512MBらしい。とはいえ、chromeを動かすだけなら大丈夫なのでは?と思うがクラッシュする。。

対応

以下によると、起動するchromeのwindowサイズを小さくすればいいらしい。 qiita.com

コード

options = Selenium::WebDriver::Chrome::Options.new

options.add_argument('--headless')
# windowを小さくしてみた
options.add_argument('window-size=500,500')
@driver = Selenium::WebDriver.for :chrome, options: options

結果

クラッシュの頻度は減ったが、依然クラッシュは起きる。 freeコマンドで使えるメモリの領域を見たが、スペックの限りは空き容量は作れている。

              total        used        free      shared  buff/cache   available
Mem:       62914728    35695900     5607412       82484    21611416    26619456
Swap:      63963132      828904    63134228

課金するしかないのか。。??