From 53bc06c23d7657ff5113baa764bde5b1c75e106d Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 20 May 2022 14:03:34 +0100 Subject: [PATCH] Fix watcher breakage on failed builds (#347) After switching to `async`/`await` the value of `isBuildCurrentlyRunning` wasn't correctly reset, which led to issues. By resetting the variable in `defer` we guarantee that it will be reset even when errors are thrown. Resolves #339. --- Sources/CartonKit/Server/Server.swift | 3 ++- Tests/Fixtures/NodeJSKitTest/.gitignore | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/CartonKit/Server/Server.swift b/Sources/CartonKit/Server/Server.swift index 6b9d62c..7a9f0b4 100644 --- a/Sources/CartonKit/Server/Server.swift +++ b/Sources/CartonKit/Server/Server.swift @@ -201,6 +201,8 @@ public actor Server { } isBuildCurrentlyRunning = true + defer { isBuildCurrentlyRunning = false } + // `configuration.builder` is guaranteed to be non-nil here as its presence is checked in `init` try await run(configuration.builder!, configuration.terminal) @@ -213,7 +215,6 @@ public actor Server { } isSubsequentBuildScheduled = false - isBuildCurrentlyRunning = false } private func add(pendingChanges: [AbsolutePath]) {} diff --git a/Tests/Fixtures/NodeJSKitTest/.gitignore b/Tests/Fixtures/NodeJSKitTest/.gitignore index 3b29812..9fd454c 100644 --- a/Tests/Fixtures/NodeJSKitTest/.gitignore +++ b/Tests/Fixtures/NodeJSKitTest/.gitignore @@ -7,3 +7,4 @@ DerivedData/ .swiftpm/config/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc +.vscode