Add TermWithReason support to AckTerminateAsync#1048
Merged
Conversation
Add optional reason parameter that sends "+TERM <reason>" to the server, matching the Go client's TermWithReason functionality. The reason appears in JetStream advisory events and requires NATS Server 2.10.4+. Implementation uses ArrayPool to avoid allocations. Platform-specific code paths handle netstandard2.0 vs newer targets for optimal performance.
also code cleanup
Member
Author
|
Alternative non breaking change using extension method: public static class NatsJSMsgExtensions
{
public static ValueTask AckTerminateAsync<T>(
this NatsJSMsg<T> msg,
string reason,
AckOpts? opts = null,
CancellationToken cancellationToken = default)
{
return msg.AckTerminateInternalAsync(reason, opts, cancellationToken);
}
}Down side not useful for testing |
mtmk
marked this pull request as draft
January 23, 2026 12:41
Member
Author
|
we can probably take the risk of breaking |
mtmk
marked this pull request as ready for review
February 24, 2026 12:57
Merged
mtmk
added a commit
that referenced
this pull request
Mar 13, 2026
* Add optional window_size parameter to StreamSnapshotRequest (#1088) * Bump Microsoft.Bcl.Memory from 9.0.0 to 9.0.14 (#1089) * Fix `PingCommand` cancellation (#1086) * rework terminate reason (#1081) * Fix OTel network telemetry tags (#1078) * Add consumer info usage warnings (#1079) * Add TermWithReason support to AckTerminateAsync (#1048) * Fix code analyser warning (#1076) * Add cancelled token handling for consumers (#1068) * Add validation for unsupported PinnedClient calls (#1063) * Add see-also references to Orbit packages (#1077) * Add Synadia.Orbit.Testing.NatsServerProcessManager (#1065) * Add slow consumer docs (#1073) * Fix error logs URI rewritten by OnConnectingAsync (#1067) * Add more tests for JetStream consumer behavior (#1055)
Merged
mtmk
added a commit
that referenced
this pull request
Mar 13, 2026
* Add optional window_size parameter to StreamSnapshotRequest (#1088) * Bump Microsoft.Bcl.Memory from 9.0.0 to 9.0.14 (#1089) * Fix `PingCommand` cancellation (#1086) * rework terminate reason (#1081) * Fix OTel network telemetry tags (#1078) * Add consumer info usage warnings (#1079) * Add TermWithReason support to AckTerminateAsync (#1048) * Fix code analyser warning (#1076) * Add cancelled token handling for consumers (#1068) * Add validation for unsupported PinnedClient calls (#1063) * Add see-also references to Orbit packages (#1077) * Add Synadia.Orbit.Testing.NatsServerProcessManager (#1065) * Add slow consumer docs (#1073) * Fix error logs URI rewritten by OnConnectingAsync (#1067) * Add more tests for JetStream consumer behavior (#1055)
This was referenced Jul 12, 2026
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add optional
reasonparameter toAckTerminateAsyncthat sends+TERM <reason>to the server, matching the Go client'sTermWithReasonfunctionality.The reason appears in JetStream advisory events (requires NATS Server 2.10.4+).
Low-allocation implementation using
ArrayPool<byte>with platform-specific optimizations for netstandard2.0 vs newer targets.INatsJSMsg<T>I only expect tests would break and can be detected and fairly easily fixed during build. However, if applications are using their own implementations of
INatsJSMsg<T>they will break during build too but more severely if they are transitive dependencies using an earlier version ofNATS.Client.JetStreamthey would fail at runtime.Interface
INatsJSMsg<T>Changesdefault→nullonReplyAsyncparamsdefault→nullonAckAsyncparamdefault→nullonNakAsyncparamdefault→nullonAckProgressAsyncparamdefault→nullonAckTerminateAsyncparamAckTerminateAsync(string reason, ...)Struct
NatsJSMsg<T>Changesdefault→nullon all method paramsAckTerminateAsync(string reason, ...)delay == default→delay == TimeSpan.ZeroConnection == default→Connection == null<inheritdoc />NatsJSMsgConstantsclassFinal Verdict
NatsJSMsg<T>directlyINatsJSMsg<T>INatsJSMsg<T>Breaking Change Details
What breaks:
How it breaks:
Scenario: Source break
Failure Mode: Compilation error when updating package and recompiling
Scenario: Binary break
Failure Mode: TypeLoadException at runtime if old compiled mock is loaded with new library version (transitive dependency scenario)
Who is affected:
Who is NOT affected:
Risk Assessment
Factor: Likelihood of user interface implementations
Assessment: Medium - Interface docs explicitly mention "creating test doubles in unit testing"
Factor: Severity of break
Assessment: High - TypeLoadException crashes app at startup
Factor: Detectability
Assessment: Low for transitive - User may not know they have a dependency with an implementation
Factor: SemVer classification
Assessment: Breaking change - requires major version bump per SemVer
Conclusion
The current implementation is a breaking change.
It will cause TypeLoadException at runtime for any code that implements INatsJSMsg, including through transitive dependency updates where the user never modified their own code.