Cap client operation limits to MaxArrayLength and fix flaky pcap/interval tests#3910
Merged
Conversation
…dard into flakinessfixes
FetchOperationLimitsAsync now clamps ServerCapabilities.MaxArrayLength by the client's TransportQuotas.MaxArrayLength and caps all operation limits to that effective value (treating 0 as unlimited), so SessionClientBatched never sends an operations array larger than the server accepts. Adds unit tests and a Sessions.md note.
5 tasks
marcschier
commented
Jun 23, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3910 +/- ##
==========================================
+ Coverage 72.75% 72.77% +0.01%
==========================================
Files 917 917
Lines 149022 149057 +35
Branches 25816 25821 +5
==========================================
+ Hits 108426 108474 +48
+ Misses 31176 31166 -10
+ Partials 9420 9417 -3
🚀 New features to boost your workflow:
|
Rephrase the Sessions.md operation-limit note so the server-reported 0/over-limit cases are explicit, and simplify the TransportQuotas.MaxArrayLength int->uint cast.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OPC UA client’s operation-limit handling to ensure batched service requests never exceed the effective MaxArrayLength (server capability clamped by client TransportQuotas), addressing scenarios where servers reject oversized operations arrays with BadEncodingLimitsExceeded. It also includes two unrelated test-stability improvements.
Changes:
- Cap per-service
OperationLimitsto the effectiveMaxArrayLengthinSession.FetchOperationLimitsAsync. - Add unit tests covering server cap, “0/unlimited” behavior, client-quota cap, and the no-cap case.
- Stabilize two flaky timing/pcap-related tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Libraries/Opc.Ua.Client/Session/Session.cs | Implements MaxArrayLength clamping and caps all operation limits to the effective array-length bound. |
| Tests/Opc.Ua.Client.Tests/Session/SessionTests.cs | Adds tests validating capping behavior across server/client/unlimited cases. |
| Docs/Sessions.md | Documents how FetchOperationLimitsAsync derives effective limits using MaxArrayLength. |
| Tests/Opc.Ua.Core.Diagnostics.Tests/Capture/InProcessClientCaptureSourceTests.cs | Improves determinism by explicitly draining the capture worker before forced disposal. |
| Tests/Opc.Ua.PubSub.Tests/IntervalRunnerTests.cs | Makes the polling helper more tolerant of CI thread-pool starvation and reduces spin frequency. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
romanett
approved these changes
Jun 24, 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.
Description
This branch contains two independent changes.
1. Honor
MaxArrayLengthfor service-operation arrays (Fixes #3909)MaxArrayLengthapplies to every array in a decoded message, including service-operation arrayssuch as
nodesToRead, and a server returnsBadEncodingLimitsExceededif it is exceeded. The twolimits are independent in the spec (nothing requires
MaxNodesPerRead <= MaxArrayLength), but becausethe operation array is itself a decoded array, the sender must honor both bounds.
Previously the client trusted each
OperationLimitsvalue verbatim. With a server advertising, forexample,
MaxNodesPerRead = 10000andMaxArrayLength = 1000, the complex-type loader (and any otherbatched service call) packed more than 1000 reads into a single request, which the server rejected. The
same happened when an operation limit was
0(unlimited), which disables batching inSessionClientBatched.Session.FetchOperationLimitsAsyncnow:ServerCapabilities.MaxArrayLengthby the client's configuredTransportQuotas.MaxArrayLength(mirroring the existing
MaxByteStringLengthhandling) to obtain an effective array length, and0(unlimited) or a limit largerthan the effective length is reduced to it, while
0/unlimited on both sides leaves the limitsunchanged.
SessionClientBatchedthen batches Read/Write/Browse/… calls using the capped limits, so a singlerequest never produces an operations array larger than the server will accept. This directly fixes the
reported scenario where the complex type system read more than
MaxArrayLengthnodes in one request.No public API change; behavior remains compatible with 1.5.378. A behavior note was added to
Docs/Sessions.md, and unit tests cover the cap, the0/unlimited case, the client-quota case, and theno-op case.
2. Fix flaky tests
Tests/Opc.Ua.Core.Diagnostics.Tests/.../InProcessClientCaptureSourceTests.cs— stabilizes thein-process pcap capture test.
Tests/Opc.Ua.PubSub.Tests/IntervalRunnerTests.cs— stabilizes the interval runner timing test.These flakiness fixes are unrelated to #3909 and are included on the same branch.
Related Issues
Checklist
Put an
xin the boxes that apply. You can complete these step by step after opening the PR.