From c6e5b5932cd5c0aba603e950b8a2ce925125092e Mon Sep 17 00:00:00 2001 From: Luka Date: Wed, 12 Feb 2025 17:11:11 +0100 Subject: [PATCH] fix(lib): hanging after tool installation (#5) Fixes an issue where the process sometimes hangs indefinitely after installation of a tool. This is done by removing the usage of `task.cancel` within the code for progress bars, and instead checking the `finished` value within the task. --- toolchainlib/src/utils/progress.luau | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/toolchainlib/src/utils/progress.luau b/toolchainlib/src/utils/progress.luau index 9d25637..d9801b6 100644 --- a/toolchainlib/src/utils/progress.luau +++ b/toolchainlib/src/utils/progress.luau @@ -53,8 +53,12 @@ function ProgressBar.start(self: ProgressBarImpl): () end self.thread = task.spawn(function() - while not self.finished do + while true do for _, spinner in SPINNERS do + if self.finished then + return + end + local stage = self.stages[self.currentStageIndex] stdio.ewrite( `\x1b[2K\x1b[0G{stdio.color("cyan")}{spinner} {stage.message}{stdio.color("reset")}{string.rep( @@ -77,7 +81,6 @@ end function ProgressBar.stop(self: ProgressBarImpl): () -- Trigger upvalue, kill thread and clean progress bar remnant self.finished = true - task.cancel(self.thread :: thread) stdio.ewrite("\x1b[2K\x1b[0G") end