Skip to content

Commit 50ee6fa

Browse files
authored
Improve logging when Hangfire operation canceled (#874)
1 parent ea081c6 commit 50ee6fa

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Machine/src/Serval.Machine.Shared/Services/HangfireBuildJob.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ CancellationToken cancellationToken
5555

5656
await DoWorkAsync(engineId, buildId, data, buildOptions, cancellationToken);
5757
}
58-
catch (OperationCanceledException)
58+
catch (OperationCanceledException e)
5959
{
60+
// Log the full exception for debugging purposes
61+
Logger.LogInformation(e, "Build Hangfire job canceled ({0})", buildId);
62+
6063
// Check if the cancellation was initiated by an API call or a shutdown.
6164
TEngine? engine = await Engines.GetAsync(
6265
e => e.EngineId == engineId && e.CurrentBuild != null && e.CurrentBuild.BuildId == buildId,
@@ -93,10 +96,12 @@ await DataAccessContext.WithTransactionAsync(
9396
},
9497
cancellationToken: CancellationToken.None
9598
);
99+
Logger.LogInformation("Build restarting ({0})", buildId);
96100
throw;
97101
}
98102
else
99103
{
104+
Logger.LogInformation("Build engine not found ({0})", buildId);
100105
completionStatus = JobCompletionStatus.Canceled;
101106
}
102107
}

0 commit comments

Comments
 (0)