Repository navigation
Make LatencyPlugin's maxMs inclusive - #1930
Merged
Merged
Conversation
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix LatencyPlugin to apply inclusive maxMs
Make LatencyPlugin's maxMs inclusive
Oct 20, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix handles inclusive bounds safely with regression coverage; tests were not executed.
No open issues 🎉
What changed in this PR
Fixes #1927 by allowing LatencyPlugin to select the configured maxMs delay.
Changes:
- Uses a shared, overflow-safe inclusive delay calculation for HTTP and stdio.
- Adds regression coverage for inclusive, equal, and
int.MaxValuebounds.
| File | Description |
|---|---|
| DevProxy.Plugins/Behavior/LatencyPlugin.cs | Applies inclusive bounds to both delay paths. |
| DevProxy.Integration.Tests/BehaviorPluginsIntegrationTests.cs | Tests upper-bound inclusion and boundary cases. |
Review effort: Balanced
waldekmastykarz
marked this pull request as ready for review
October 20, 2026 17:49
Collaborator
|
@copilot build is failing. Fix |
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Contributor
Author
Fixed the locked-restore failure by updating the dependent NuGet lock files. The locked restore, solution build, and focused latency tests pass. Commit: |
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.
LatencyPluginpicked its delay withRandom.Next(MinMs, MaxMs). That method excludes the upper bound, so the configuredmaxMswas never applied. The schema describesmaxMsas the maximum delay, so it should be a possible value.Changes
LatencyPlugin: bothApplyDelayAsyncoverloads (HTTP and stdio) now call a new internal helper,GetDelay, which picks fromminMstomaxMsinclusive. The upper bound is computed as along, soMaxMs + 1can't overflow whenmaxMsisint.MaxValue.Tests (
BehaviorPluginsIntegrationTests): the new test checks three cases:0..1, the delay is sometimes 1. The old code always returned 0.min == max, the delay equals that value.maxMs = int.MaxValuedoesn't overflow.GetDelayis reachable from the tests through the existingInternalsVisibleToentry.minMs > maxMsstill throws, as it did before.