Github actions job cancelled for no obvious reason
Asked Answered
H

2

16

I'm trying to set up a github actions script for a project of mine. The project is private at the moment since I want it in an RC state before the first release. As it is close to ready, I intended to set up an automated build now, but I'm seeing some strange behavior. The project is a simple c# library, and so the .yml file is quite simple:


name: .NET Core Desktop

on: [push, pull_request]

jobs:

  build:

    strategy:
      matrix:
        configuration: [Debug, Release]

    runs-on: windows-latest  

    env:
      Solution_Name: Replacement.sln                         # Replace with your solution name, i.e. MyWpfApp.sln.
      Test_Project_Path: UnitTest.csproj                 # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.

    steps:
    - name: Checkout
      uses: actions/checkout@v3
      with:
        fetch-depth: 0

    # Run build
    - name: Run build
      run: ./build.cmd --target pack --configuration ${{ matrix.configuration }}

Sometimes, one of the builds (Debug or Release, or both) fail with an entry such as

Terminate batch job (Y/N)? 
Error: The operation was canceled.

in the log. I certainly did not cancel the build in any way. This may happen after like 3 minutes.

Am I running into the github build time limit (how would I know)? Or is there something else wrong I'm missing?

Heigho answered 3/6, 2022 at 12:39 Comment(4)
As it seems the workflow ask for a manual interaction before cancelling your job (Terminate batch job (Y/N)?), the server might be cancelling the job automatically after 5 min with no action (reference)Aphaeresis
@Aphaeresis This happens after an overall runtime of only 3 minutes, the last output being about a second old.Heigho
We had something similar at work today, but using a self-hosted runner. It worked after retrying 3 times. Did your workflow normalize, or is cancellation still happening?Aphaeresis
It appears to work now. Maybe it was because I started to many builds in short succession (as of course it wasn't working right from the start)Heigho
M
9

Add fail-fast: false

    strategy:
      fail-fast: false
      matrix: ...
Mighty answered 29/5, 2023 at 18:0 Comment(3)
What is that supposed to do, exactly?Heigho
docs.github.com/en/actions/using-jobs/…Vito
With this change, I got exit code "143" instead of "1", so slightly better, but it is still not telling me why it is failing. I can only guess if it is memory, disk, or something else, or have to interrogate these manually.Labbe
C
3

One of the many possible reasons for getting a "Error: The operation was canceled" is having a timeout somewhere in your GitHub Actions YAML files.

jobs:
  something:
    name: do something
    runs-on: ubuntu-latest
    timeout-minutes: 10 # Consider increasing timeout

It's easy to miss as the timeout could be defined in a different file than your failing step is.

Crocus answered 25/8, 2023 at 10:25 Comment(2)
What do you mean by "in a different file"? There's only this yml file.Heigho
In more complex CI/CD systems using GitHub Actions, the workflow may be defined in multiple files. If you only have one file and that doesn't have a timeout, my answer is not applicable to you. I wanted to mention the timeout (even though it might not solve your problem) because I spent an hour trying to find why my jobs are getting cancelled, so I hope I can prevent that someone else has to waste so much time as I had to.Crocus

© 2022 - 2024 — McMap. All rights reserved.