From 006783101de21965869f16cb50094748e119123f Mon Sep 17 00:00:00 2001 From: Mouad Debbar Date: Thu, 30 Jan 2025 15:40:19 -0500 Subject: [PATCH] Limit number of retries when downloading the Dart SDK on Windows (#162411) Disclaimer: I have no idea what I'm doing. I never wrote `.bat` code before. Fixes https://github.com/flutter/flutter/issues/162410 --- bin/internal/shared.bat | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/internal/shared.bat b/bin/internal/shared.bat index 3fa3a3be23..187116e8d9 100644 --- a/bin/internal/shared.bat +++ b/bin/internal/shared.bat @@ -145,6 +145,7 @@ GOTO :after_subroutine ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1>&2 EXIT 1 ) + SET /A dart_sdk_retries+=1 ECHO Checking Dart SDK version... 1>&2 SET update_dart_bin=%FLUTTER_ROOT%\bin\internal\update_dart_sdk.ps1 REM Escape apostrophes from the executable path @@ -157,7 +158,13 @@ GOTO :after_subroutine IF "%ERRORLEVEL%" EQU "2" ( EXIT 1 ) + SET max_dart_sdk_retries=3 IF "%ERRORLEVEL%" NEQ "0" ( + IF "%dart_sdk_retries%" EQU "%max_dart_sdk_retries%" ( + ECHO Error: Unable to update Dart SDK after %max_dart_sdk_retries% retries. 1>&2 + DEL "%engine_stamp%" + EXIT 1 + ) ECHO Error: Unable to update Dart SDK. Retrying... 1>&2 timeout /t 5 /nobreak GOTO :do_sdk_update_and_snapshot