actions / actions/runner

Background actions frequently fail on Windows due to locking event.json

Open
#4,641 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug

Every action step writes the event.json file before executing, which causes action-based background steps to frequently fail on Windows due to file-locking.

To Reproduce

In this repository I made a simple reusable action at the top of the repo:

runs:
  using: 'composite'
  steps:
    - run: echo hello
      shell: bash

I then added a workflow to execute that a bunch on Linux and Windows:

on: push

jobs:
  job:
    runs-on:  ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        counter: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
    steps:
      - parallel:
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/
        - uses: $/

Expected behavior

The Linux ones always pass, unsurprisingly. This is the expected behaviour.

Runner Version and Platform

2.336.0 on windows-latest (and self-hosted Windows, with the same runner version)

What's not working?

On Windows, steps frequently fail with this error:

Error: The process cannot access the file 'D:\a_temp_github_workflow\event.json' because it is being used by another process.

I think this is likely due to this bit of code in the runner which writes event.json for every action. See ActionRunner.RunAsync() in the stack trace below.

Job Log Output

From https://github.com/j3parker/github-actions-parallel-tests/actions/runs/32063332105

With debugging enabled:

##[debug]Evaluating condition for step: 'Run j3parker/github-actions-parallel-tests@7c5d69fbd5a4044bbb0ec5b455cdd283177dd7d6'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Loading inputs
##[debug]Loading env
Run j3parker/github-actions-parallel-tests@7c5d69fbd5a4044bbb0ec5b455cdd283177dd7d6
##[debug]Set step '' display name to: 'Run echo hello'
Run echo hello
0s
  ##[debug]Evaluating condition for step: 'Run echo hello'
  ##[debug]Evaluating: success()
  ##[debug]Evaluating success:
  ##[debug]=> true
  ##[debug]Result: true
  ##[debug]Starting: Run echo hello
  Error: The process cannot access the file 'D:\a\_temp\_github_workflow\event.json' because it is being used by another process.
  ##[debug]System.IO.IOException: The process cannot access the file 'D:\a\_temp\_github_workflow\event.json' because it is being used by another process.
  ##[debug]   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
  ##[debug]   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
  ##[debug]   at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
  ##[debug]   at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding)
  ##[debug]   at GitHub.Runner.Worker.ExecutionContext.WriteWebhookPayload()
  ##[debug]   at GitHub.Runner.Worker.ActionRunner.RunAsync()
  ##[debug]   at GitHub.Runner.Worker.Handlers.CompositeActionHandler.RunStepAsync(IStep step)
  ##[debug]Finished: Run echo hello

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/Runner.Worker/ActionRunner.cs around the referenced line and follow ExecutionContext.WriteWebhookPayload in the stack trace. Reproduce the issue using the linked parallel-actions workflow on Windows with repeated composite-action steps. Done means concurrent background action steps no longer fail because event.json is locked.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, github-actions
Domain
ci-cd, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.