Investigating Job Cancellations in GitHub Actions by Enabling Debug Logging
One day, a regularly scheduled job in GitHub Actions suddenly started failing. I investigated the cause by utilizing GitHub Actions’ debug logging feature, so I’d like to share that process with you.
When checking the error logs, the following message was displayed:
##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.
················ ELIFECYCLE Command failed.
##[error]The operation was canceled.
While this log tells us that the runner received a shutdown signal, it’s difficult to identify the specific cause of why this happened.
Even looking at the failed job logs, no additional information was available.
In such situations, GitHub Actions’ debug logging feature becomes very useful. When debug logging is enabled, more detailed information about workflow execution is output, making it easier to obtain clues that lead to identifying the root cause of problems.
The method to enable debug logging is very simple:
ACTIONS_RUNNER_DEBUG
true
The setup is now complete. When you re-run the workflow in this state, detailed logs will be output.
When I actually enabled debug logging and re-executed the workflow, the log output increased dramatically.
Job logs with debug logging enabled
Many lines with the prefix ##[debug]
were added to the logs, recording internal operations of each step, API calls, and environment variables with masking applied.
················ ELIFECYCLE Command failed.
Error: The operation was canceled.
##[debug]System.OperationCanceledException: The operation was canceled.
##[debug] at System.Threading.CancellationToken.ThrowOperationCanceledException()
##[debug] at GitHub.Runner.Sdk.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Channel`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken)
##[debug] at GitHub.Runner.Common.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Channel`1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, CancellationToken cancellationToken)
##[debug] at GitHub.Runner.Worker.Handlers.DefaultStepHost.ExecuteAsync(IExecutionContext context, String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, String standardInInput, CancellationToken cancellationToken)
##[debug] at GitHub.Runner.Worker.Handlers.ScriptHandler.RunAsync(ActionRunStage stage)
##[debug] at GitHub.Runner.Worker.ActionRunner.RunAsync()
##[debug] at GitHub.Runner.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
##[debug]Finishing: Run e2e tests
This enables more detailed tracking of which command at which timing is causing unexpected behavior.
When encountering errors of unknown cause in GitHub Actions, I recommend first enabling debug logging. Simply setting ACTIONS_RUNNER_DEBUG
to true
can potentially provide many hints that lead to problem resolution. Please try this method as a first step in troubleshooting.
That’s all from the Gemba.