Skip to content

Commit e243dbc

Browse files
committed
fix: concurrent publish race and timeout-skipped record step
Bug 1: publishEntry re-reads and re-merges after writing so a concurrent publish that edited from a stale body does not silently lose the other writer's entry. Without compare-and-swap, two writers that both merge from the same initial body can overwrite each other; the first writer's verify passes before the second write lands and returns, losing the entry. The re-merge step absorbs entries the initial write clobbered. Bug 2: The 'Record the review' step now uses always() so a Claude timeout (or any other step-level failure) does not skip growth publishing. The || handler only covers a non-zero CLI exit; a GitHub timeout kills the process without invoking it, failing the step and gating the implicit success() condition on the record step.
1 parent 25dae0d commit e243dbc

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎.github/workflows/size-review.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139
|| { echo "::warning::Claude review failed; the issue records the growth only"; rm -f "$RESULTS/review/analysis.md"; }
140140
141141
- name: Record the review in the size issue
142-
if: steps.growth.outputs.grew == 'true'
142+
if: always() && steps.growth.outputs.grew == 'true'
143143
env:
144144
GH_TOKEN: ${{ github.token }}
145145
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

‎benchmarks/size-review.mjs‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,23 @@ export function publishEntry(github, { entry, headSha, repository, minGzip }) {
290290
for (const duplicate of duplicates) {
291291
github.close(duplicate.number, `Folded into #${number}.`);
292292
}
293-
const [oldest] = github.openIssues();
294-
if (oldest !== undefined && github.body(oldest.number).includes(entryStart(headSha))) {
293+
// Re-read and re-merge so a concurrent publish that edited from a stale
294+
// body does not silently lose our entry (or we theirs). Without a
295+
// compare-and-swap API the first writer's verify can pass before the
296+
// second write lands; re-merging from the post-write body recovers both.
297+
const [oldest, ...lateDuplicates] = github.openIssues();
298+
if (oldest === undefined) continue;
299+
const current = github.body(oldest.number);
300+
const settled = mergeIssueBody(
301+
[...lateDuplicates.map(({ body }) => body), current],
302+
entry,
303+
options,
304+
);
305+
if (settled !== current) github.edit(oldest.number, settled);
306+
for (const dup of lateDuplicates) {
307+
github.close(dup.number, `Folded into #${oldest.number}.`);
308+
}
309+
if (settled.includes(entryStart(headSha))) {
295310
return oldest.number;
296311
}
297312
console.warn(

‎benchmarks/size-review.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,6 @@ test('the workflow reviews main after the push and keeps Claude read-only', () =
256256
assert.match(claude, /@anthropic-ai\/claude-code@\d+\.\d+\.\d+ /);
257257
assert.doesNotMatch(claude, /GH_TOKEN|github\.token/);
258258
const record = step('Record the review in the size issue');
259-
assert.match(record, /if: steps\.growth\.outputs\.grew == 'true'\n/);
259+
assert.match(record, /if: always\(\) && steps\.growth\.outputs\.grew == 'true'\n/);
260260
assert.doesNotMatch(record, /ANTHROPIC/);
261261
});

0 commit comments

Comments
 (0)