Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kfollesdal
Copy link
Contributor

Description:

Fixes a bug where pipelines with named NATS consumers would fail with "consumer already exists" errors during rapid restarts or replays, before the previous consumer expires (inactive_threshold).

Changes:

  • Append a unique UUID suffix to named consumers to avoid name collisions
  • If no name is configured, NATS auto-generates a random name (no change needed)
  • Add test verifying named consumers work correctly during restart/replay cycles
  • Improve error context when consumer creation fails

Checklist

  • Documentation updated
  • Changelog updated

Breaking Changes?

Mark if you think the answer is yes for any of these components:

Describe Incompatible Changes

Copilot AI review requested due to automatic review settings January 28, 2026 16:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the NATS adapter where pipelines with named consumers would fail with "consumer already exists" errors during rapid restarts or replays before the previous consumer expires.

Changes:

  • Append a UUID suffix to named NATS consumers to prevent name collisions
  • Add error context when consumer creation fails
  • Add test case verifying named consumers work correctly during restart/replay cycles

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/adapters/src/transport/nats/input.rs Implements UUID suffix for named consumers and improves error messaging
crates/adapters/src/transport/nats/input/test.rs Adds test infrastructure and test case for named consumer restart/replay scenarios

.create_consumer_strict_on_stream(consumer_config, stream_name)
.await?)
// Add a unique suffix to named consumers.
// If consumer is unamed, NATS automatically generates a random name.
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'unamed' to 'unnamed'.

Suggested change
// If consumer is unamed, NATS automatically generates a random name.
// If consumer is unnamed, NATS automatically generates a random name.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a useful suggestion

Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to make a clone this PR in order to merge it... our CI still does not like external contributions.

.create_consumer_strict_on_stream(consumer_config, stream_name)
.await?)
// Add a unique suffix to named consumers.
// If consumer is unamed, NATS automatically generates a random name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a useful suggestion

@blp
Copy link
Member

blp commented Jan 28, 2026

@kfollesdal Please add Signed-off-by to these commits since we use the DCO.

Thank you! I'm continuing to review this.

@blp
Copy link
Member

blp commented Jan 28, 2026

Besides the need for DCO, this seems easy to approve. Thanks!

@kfollesdal
Copy link
Contributor Author

@blp Will do. I’m off my computer now, but I’ll take care of it when I’m back at it.

Add test to check that we do not get error/bug "consumer exist", that we
got when pipeline with a named nats consumer got restarted/replayed.

Signed-off-by: kfollesdal <[email protected]>
This is a fix for the bug "consumer exist" that we get when we had a
named NATS consumer in a pipline that got restarted/replayed.

Signed-off-by: kfollesdal <[email protected]>
@kfollesdal kfollesdal force-pushed the nats-named-consumer-fix branch from ef211ea to 0436564 Compare January 28, 2026 21:00
@kfollesdal
Copy link
Contributor Author

Thanks @blp, I have now signed off the commits.

@blp
Copy link
Member

blp commented Jan 28, 2026

This is going to merge via #5526, so I closing it in favor of that one (sorry about our awkward process).

@blp blp closed this Jan 28, 2026
@kfollesdal kfollesdal deleted the nats-named-consumer-fix branch January 29, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants