Skip to content

fix(cli): don't re-run listeners when replaying corked messages#1701

Merged
aws-cdk-automation merged 1 commit into
mainfrom
sai/fix-cork-replay-reruns-listeners
Jul 2, 2026
Merged

fix(cli): don't re-run listeners when replaying corked messages#1701
aws-cdk-automation merged 1 commit into
mainfrom
sai/fix-cork-replay-reruns-listeners

Conversation

@sai-ray

@sai-ray sai-ray commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Messages emitted while logging is corked are buffered and replayed through notify() when the cork releases. notify() re-ran the message listeners on that replay, so a listener that transforms a message (e.g. a rewrite) ran a second time on its own already-transformed output.

This skips applyMessageListeners while corkReplaying, matching the existing guard that already skips observers on replay. Listeners now run exactly once, on the first pass.

The visible case: under --yes, the auto-confirm suffix is added (via writeMessage) after listeners run, while corked. On replay, a rewrite listener on that request code would clobber the suffix. This is latent on main today (nothing registers such a listener yet) but blocks the cdk deploy reroute in #1585.

Test plan

  • Unit test in test/cli/io-host/cli-io-host.test.ts: a rewrite listener fires once through a corked replay, not again on the replayed message. Verified it fails without the fix (listener runs twice) and passes with it.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Messages emitted while corked are buffered and later replayed through
notify() when the cork releases. notify() re-ran the message listeners on
that replay, so a listener that transforms a message (e.g. a rewrite) ran
a second time on its own output. Skip applyMessageListeners while
corkReplaying, matching the existing guard that already skips observers.

One unit test on CliIoHost proving a rewrite fires once through cork replay.
@aws-cdk-automation aws-cdk-automation requested a review from a team July 2, 2026 05:06
@github-actions github-actions Bot added the p2 label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.62%. Comparing base (057c6fb) to head (2f82064).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1701   +/-   ##
=======================================
  Coverage   89.62%   89.62%           
=======================================
  Files          77       77           
  Lines       11746    11752    +6     
  Branches     1649     1650    +1     
=======================================
+ Hits        10527    10533    +6     
  Misses       1190     1190           
  Partials       29       29           
Flag Coverage Δ
suite.unit 89.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Jul 2, 2026
Merged via the queue into main with commit 200c183 Jul 2, 2026
46 checks passed
@aws-cdk-automation aws-cdk-automation deleted the sai/fix-cork-replay-reruns-listeners branch July 2, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants