-
Notifications
You must be signed in to change notification settings - Fork 447
Description
Human Preface/Disclaimer
The only issue I actually saw/can confirm was the double storybook comments in #5274, but I do not know the cause of this issue.
Everything below this point is completely triaged and generated by Opus 4.1 Claude Code.
Problem Description
When multiple commits are pushed to a PR in quick succession, duplicate "Storybook Build Status" comments are created instead of updating a single comment. This was observed in PR #5274 where two identical Storybook status comments were posted.
Root Cause Analysis
Each commit triggers its own Chromatic workflow run, and each Chromatic run triggers a separate pr-storybook-comment workflow via the workflow_run event. When these workflows run concurrently or in rapid succession, a race condition occurs:
- Both workflows search for existing comments with
<!-- STORYBOOK_BUILD_STATUS -->marker - Neither finds the other's comment (as they're created nearly simultaneously)
- Both create new comments instead of updating an existing one
Timeline Example (from PR #5274)
- Commit 1 (33035ee at 00:22:04Z) → Chromatic run no. 423 → Comment created at 12:22:57
- Commit 2 (91ad2a0 at 00:25:50Z) → Chromatic run no. 424 → Comment created at 12:26:17
Proposed Solutions
Option 1: Add Concurrency Control (Recommended)
Add concurrency settings to pr-storybook-comment.yaml to ensure only one instance runs per PR:
concurrency:
group: storybook-comment-${{ github.event.workflow_run.pull_requests[0].number }}
cancel-in-progress: trueOption 2: Use More Specific Comment Markers
Include additional identifiers in the comment marker to prevent collisions:
body-includes: '<!-- STORYBOOK_BUILD_STATUS_PR_${{ steps.pr.outputs.result }} -->'Option 3: Add Delay and Retry Logic
Implement a small delay and retry mechanism to check for recently created comments before creating a new one.
Impact
- Creates confusion with multiple status comments on PRs
- Clutters PR discussion threads
- May cause notification spam for PR participants
Related Information
- Issue introduced after PR [feat] Implement pull_request_target deployment for forked PRs - solves secret access issue #5209 which implemented the
workflow_runarchitecture for CI comment/deploy separation - Affects both
pr-storybook-comment.yamland potentiallypr-playwright-comment.yamlworkflows
┆Issue is synchronized with this Notion page by Unito