Skip to content

Duplicate Storybook build status comments on PRs #5275

@benceruleanlu

Description

@benceruleanlu

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:

  1. Both workflows search for existing comments with <!-- STORYBOOK_BUILD_STATUS --> marker
  2. Neither finds the other's comment (as they're created nearly simultaneously)
  3. 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: true

Option 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 is synchronized with this Notion page by Unito

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions