Skip to content

fix(ci): Keep event-file readers out of parallel and background steps - #127616

Merged
billyvg merged 1 commit into
masterfrom
billyvg/ci/fix-event-json-race
Oct 16, 2026
Merged

billyvg merged 1 commit into
masterfrom
billyvg/ci/fix-event-json-race

Conversation

@billyvg

@billyvg billyvg commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Why?

Jest shards and acceptance jobs sometimes fail before any tests run, with SyntaxError: Unexpected end of JSON input. The runner truncates and rewrites $GITHUB_EVENT_PATH every time a step starts (actions/runner#4641). Meanwhile actions/setup-node, pnpm/action-setup, actions/download-artifact and dawidd6/action-download-artifact parse that file when they start. The jest job now sets up inside a parallel: group, and acceptance runs setup-sentry as a background: step, so those actions sometimes read the file while another step is rewriting it. The issue has the evidence and failure counts.

How?

Node and pnpm are installed before anything runs concurrently. The jest artifact downloads are replaced with a gh script, which doesn't read the event file and retries transient artifact API errors. After this change, nothing that reads the event file runs while other steps are running.

Decisions

  • Keep parallel: and background: rather than reverting them.
    • Jest: setup takes about as long as before (22s here, against 21s for a master shard).
    • Acceptance: the background step now starts about 12s later, once Node and pnpm are installed. That only costs time when the webpack cache is warm, because then the background step is already the slowest path. On this PR's run, setup before tests took a median of 128s, against medians of 119–128s across recent master runs.
  • A failed balance download fails the shard after retries instead of warning and continuing. A shard without jest-balance.json splits tests by file name while the other shards split by duration, so some tests would silently never run.

Generated with Claude Code

@github-actions github-actions Bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

The runner truncates and rewrites $GITHUB_EVENT_PATH every time a step
starts (actions/runner#4641). actions/setup-node, pnpm/action-setup,
actions/download-artifact and dawidd6/action-download-artifact parse that
file when they start, so running them next to a `parallel:` group or a
`background:` step intermittently fails with "SyntaxError: Unexpected end
of JSON input".

Move setup-node and pnpm/action-setup into a setup-node-toolchain
composite. The jest job and the acceptance job run it before their
concurrent steps start, and setup-node-pnpm skips it via
`setup-toolchain: 'false'`. The jest job's two artifact downloads become
one `gh` script, which doesn't read the event file and retries transient
artifact API errors.

Fixes #127566

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@billyvg
billyvg force-pushed the billyvg/ci/fix-event-json-race branch from b81fde2 to cf5f0ed Compare October 16, 2026 18:15
@billyvg
billyvg marked this pull request as ready for review October 16, 2026 18:25
@billyvg
billyvg requested review from a team as code owners October 16, 2026 18:25
@billyvg
billyvg merged commit ca8a733 into master Oct 16, 2026
84 checks passed
@billyvg
billyvg deleted the billyvg/ci/fix-event-json-race branch October 16, 2026 18:25
RudraPatel2003 pushed a commit that referenced this pull request Oct 19, 2026
…#127616)

### Why?

Jest shards and acceptance jobs sometimes fail before any tests run,
with `SyntaxError: Unexpected end of JSON input`. The runner truncates
and rewrites `$GITHUB_EVENT_PATH` every time a step starts
(actions/runner#4641). Meanwhile `actions/setup-node`,
`pnpm/action-setup`, `actions/download-artifact` and
`dawidd6/action-download-artifact` parse that file when they start. The
jest job now sets up inside a `parallel:` group, and acceptance runs
`setup-sentry` as a `background:` step, so those actions sometimes read
the file while another step is rewriting it. The issue has the evidence
and failure counts.

- Fixes #127566

### How?

Node and pnpm are installed before anything runs concurrently. The jest
artifact downloads are replaced with a `gh` script, which doesn't read
the event file and retries transient artifact API errors. After this
change, nothing that reads the event file runs while other steps are
running.

### Decisions

- **Keep `parallel:` and `background:` rather than reverting them.**
- Jest: setup takes about as long as before (22s here, against 21s for a
master shard).
- Acceptance: the background step now starts about 12s later, once Node
and pnpm are installed. That only costs time when the webpack cache is
warm, because then the background step is already the slowest path. On
this PR's run, setup before tests took a median of 128s, against medians
of 119–128s across recent master runs.
- **A failed balance download fails the shard** after retries instead of
warning and continuing. A shard without `jest-balance.json` splits tests
by file name while the other shards split by duration, so some tests
would silently never run.

<sub>Generated with Claude Code</sub>

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci(jest): shards fail with "SyntaxError: Unexpected end of JSON input" from event.json race in parallel group

2 participants