Repository navigation
Background actions frequently fail on Windows due to locking event.json #4641
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: bashI 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
Activity
MarshallOfSound commentedon Aug 22, 2026
Same root cause, different symptom on macOS/Linux. No mandatory locking there so the runner's
File.WriteAllTextinWriteWebhookPayload()never throws — it truncatesevent.jsonto 0 bytes and rewrites it at the start of every step (including every inner step of a composite action), and any sibling background step whose process is reading$GITHUB_EVENT_PATHin that window gets an empty/partial file.Anything that bundles
@actions/githubis exposed becausenew Context()doesJSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH))at module load. e.g.actions/download-artifactin aparallel:group next to a composite action:(https://github.com/electron/electron/actions/runs/32556056497/job/96994325756, runner 2.336.0, macos-15. We've hit this roughly daily across macOS and Windows hosted runners since adopting
parallel:last week. It isn't a rare overlap: a node action reachesnew Context()~250ms after its step starts, which is about how long a sibling composite takes to start its first inner step, so the read and the truncate line up almost every time and it's just a question of who wins by a millisecond.)github.eventcomes from the job message and nothing in the worker ever mutates it, so there's no reason to re-serialize and rewrite it per step in the first place. Opened #4643 to write it once per job (and atomically if it ever has to be rewritten because a step removed it), which covers both the sharing violation here and the truncated read above.kjanat commentedon Sep 6, 2026
Also reproduced on runner 2.337.0,
windows-latest: https://github.com/kjanat/zed-editor/actions/runs/34003093167/job/101405346609j3parker commentedon Sep 15, 2026
@TingluoHuang any chance this could be looked at? It kind of makes
parallelunusable at scale (degree of parallelism and workflow frequency). @MarshallOfSound has a suggested fix which is pretty straight-forward and conservative.acidoxee commentedon Oct 1, 2026
Another data point on Linux, same as described by @MarshallOfSound above (truncated
event.json→Unexpected end of JSON input).ubuntu-24.04, 4 cores)actions/github-script@v9, failing at module load before the script runs:parallel:group: arun:step and a composite action whose own inner steps includeactions/github-scriptfromJSON(steps.<id>.outputs.result)fails withThe template is not valid. … Error reading JToken from JsonReader. Path '', line 0, position 0.Our "workaround" for now would be to move any action using
@actions/githubout ofparallel:groups, but that defeats the purpose. It would be great to get one of the PRs reviewed.fix(ci): Keep event-file readers out of parallel and background steps
fix(ci): Keep event-file readers out of parallel and background steps (…
jkroepke commentedon Oct 18, 2026
Get the same error: https://github.com/prometheus-community/windows_exporter/actions/runs/39123460109/job/117663682234
fix(ci): Keep event-file readers out of parallel and background steps (…
ci: set up FFmpeg in the foreground on Windows
ci(windows): run compiler steps sequentially (#28468)