actions / actions/toolkit

[BUG] Race condition when an existing artifact is being fetched right about when new files are added there

Open
#1,235 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Sometimes, when an artifact is being updated with new files, the artifact download fails because the API lists those new files as being a part of the artifact but the files themselves haven't yet been made available though the CDN.
The client iterates over the entries, expecting that the files are already downloadable, and crashes when it gets a 404.

See the additional context links to understand the code path that leads to this. But TL;DR — adding HttpCodes.NotFound to https://github.com/actions/toolkit/blob/b36e70495fbee083eb20f600eafa9091d832577d/packages/artifact/src/internal/utils.ts#L74-L81 should fix this.

To Reproduce

Have a few sufficiently big CI matrixes depending on a job creating the initial artifact.
These matrixes should be downloading those artifacts and uploading new files there simultaneously.

You may need to do a number of restarts to hit a race condition when some of the steps that make additional files would add them close in time to the steps in other jobs making artifact downloads.

Expected behavior

Artifact file downloads should re-try on 404 Not Found.

Screenshots

N/A

Additional context

Contributor guide

Open the contributing guide

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 in packages/artifact/src/internal/utils.ts at the retry logic around lines 74–81, then review the linked context about concurrent artifact uploads and downloads. Reproduce or test the race where an artifact lists files before the CDN serves them; done means downloads retry on 404 Not Found instead of failing.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.