事象
fastlaneで動かした処理に時間がかかると、以下のようにタイムアウトが発生します。
/Users/vagrant/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/fastlane-2.210.1/fastlane_core/lib/fastlane_core/project.rb:486:in ``': execution expired (Timeout::Error)
必要に応じて、タイムアウトまでの時間を増やす対応が必要です。
環境
fastlane: 2.210.1
対応方法
fastfileに以下を記載します。
数字はタイムアウトまでに設定したい秒数を入れてください。
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "30"
解説
タイムアウト発生時時に以下のような文言が吐かれているはずです。
[06:45:23]: Command timed out after 3 seconds on try 1 of 4, trying again with a 6 second timeout...
[06:45:29]: Command timed out after 6 seconds on try 2 of 4, trying again with a 12 second timeout...
[06:45:41]: Command timed out after 12 seconds on try 3 of 4, trying again with a 24 second timeout...
(中略)
[06:46:05]: Command timed out after 24 seconds on try 4 of 4
(中略)
XXX timed out after 4 retries with a base timeout of 3. You can override the base timeout value with the environment variable FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT, and the number of retries with the environment variable FASTLANE_XCODEBUILD_SETTINGS_RETRIES
fastlaneでは、タイムアウト(FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT)のデフォルト値は3秒のようです。
公式ドキュメントには記載がありませんが、コードがその様になっています。
https://github.com/fastlane/fastlane/blob/e14064258cd784d65e30c19fe137ecbe5f5c8da7/fastlane_core/lib/fastlane_core/project.rb#L457
失敗すると、タイムアウト値を2倍にして再チャレンジします。
https://github.com/fastlane/fastlane/blob/e14064258cd784d65e30c19fe137ecbe5f5c8da7/fastlane_core/lib/fastlane_core/project.rb#L492
再試行回数(FASTLANE_XCODEBUILD_SETTINGS_RETRIES)のデフォルトは4回なので、デフォルトのまま変更していない場合、以下のように試行されます。
- 1回目:3秒
- 2回目:3 * 2 = 6秒
- 3回目:3 * 2 * 2 = 12秒
- 4回目:3 * 2 * 2 * 2 = 24秒
再試行回数も変更したい場合は、タイムアウトと同じようにfastfileでの設定が可能です。
ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"] = "2"
実行したい処理の速さや内容によって、適切な時間を設定しましょ!