Support return job result as exitcode in hosted runner.#4233
Merged
TingluoHuang merged 1 commit intomainfrom Feb 10, 2026
Merged
Support return job result as exitcode in hosted runner.#4233TingluoHuang merged 1 commit intomainfrom
TingluoHuang merged 1 commit intomainfrom
Conversation
TingluoHuang
commented
Feb 10, 2026
| public interface IJobDispatcher : IRunnerService | ||
| { | ||
| bool Busy { get; } | ||
| TaskCompletionSource<bool> RunOnceJobCompleted { get; } |
Member
Author
There was a problem hiding this comment.
We didn't use the bool other than set it to true before.
So i am expose the job result via it.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for hosted runners to return the completed job’s TaskResult as the listener process exit code, enabling improved telemetry/alerting on job failures.
Changes:
- Change
IJobDispatcher.RunOnceJobCompletedfromTaskCompletionSource<bool>toTaskCompletionSource<TaskResult>. - Update
Runnerrun-once loop to optionally translate the completed jobTaskResultinto the process return code whenACTIONS_RUNNER_RETURN_JOB_RESULT_FOR_HOSTEDis enabled. - Update L0 tests to reflect the new
TaskResult-based completion signal.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Runner.Listener/Runner.cs |
Adds hosted-runner env-var toggle and returns exit code based on TaskResult for run-once execution. |
src/Runner.Listener/JobDispatcher.cs |
Propagates run-once job completion as a TaskResult instead of a boolean. |
src/Test/L0/Listener/RunnerL0.cs |
Updates mocks to complete run-once with TaskResult.Succeeded. |
src/Test/L0/Listener/JobDispatcherL0.cs |
Updates assertions to validate TaskResult completion. |
Comments suppressed due to low confidence (2)
src/Runner.Listener/JobDispatcher.cs:352
RunOnceAsyncinitializesjobResulttoSucceededand sets_runOnceJobCompletedinfinally. IfRunAsync(...)throws, the completion source will still be set toSucceeded, which can cause hosted runners to exit with a success code even though dispatch failed. Consider catching exceptions aroundRunAsyncand setting an appropriate failure result (or setting an exception on the TCS) before signaling completion.
private async Task RunOnceAsync(Pipelines.AgentJobRequestMessage message, string orchestrationId, WorkerDispatcher previousJobDispatch, CancellationToken jobRequestCancellationToken, CancellationToken workerCancelTimeoutKillToken)
{
var jobResult = TaskResult.Succeeded;
try
{
jobResult = await RunAsync(message, orchestrationId, previousJobDispatch, jobRequestCancellationToken, workerCancelTimeoutKillToken);
}
finally
{
Trace.Info("Fire signal for one time used runner.");
_runOnceJobCompleted.TrySetResult(jobResult);
}
src/Runner.Listener/Runner.cs:592
- This PR adds new behavior to return the run-once job
TaskResultas the listener process exit code, but there doesn’t appear to be an L0 test that setsreturnRunOnceJobResult/ACTIONS_RUNNER_RETURN_JOB_RESULT_FOR_HOSTEDand asserts the returned code matchesTaskResultUtil.TranslateToReturnCode(...)(including a failure case). Adding a focused unit test would prevent regressions in the exit-code mapping.
if (returnRunOnceJobResult)
{
try
{
var jobResult = await jobDispatcher.RunOnceJobCompleted.Task;
return TaskResultUtil.TranslateToReturnCode(jobResult);
}
806598c to
14a8876
Compare
ericsciple
approved these changes
Feb 10, 2026
dawidmalina
pushed a commit
to dawidmalina/github-runner
that referenced
this pull request
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://github.com/github/hosted-compute/issues/3923