Harden archive polling helpers against transient empty reads - #960
Open
eduardosmaniotto wants to merge 1 commit into
Open
eduardosmaniotto wants to merge 1 commit into
eduardosmaniotto wants to merge 1 commit into
Conversation
WaitForPacketsAsync in NetworkObservationTests and PacketArchiveTest indexed sessions[0] unguarded and returned a possibly short session, so a slow background writer task produced a random ArgumentOutOfRangeException instead of a meaningful result. Both helpers now keep polling while the session listing (or packet list) is transiently empty and throw a descriptive TimeoutException only when the 10 s budget is actually exhausted.
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.
Problem
MUnique.OpenMU.Tests.NetworkObservationTests.TrafficOfAnObservedAccountIsArchivedAsyncfailed randomly in the Azure pipeline with
System.ArgumentOutOfRangeException: Index was out of range.The packets (and the session listing itself) are written by a
background task, so both can be transiently empty — but
WaitForPacketsAsyncindexedsessions[0]unguarded and, ontimeout, returned a session with fewer packets than requested,
which then blew up at the caller's
PacketList[0]with a index error.Fix
In
WaitForPacketsAsync(bothNetworkObservationTestsand itscopy-paste twin in
PacketArchiveTest, which had the identicallatent crash):
indexing into it;
TimeoutException(Timed out after 10 s waiting for N archived packet(s)) when the budget is genuinelyexhausted, instead of returning a short session.
No production code touched, no behavior change on the success path,
10 s budget unchanged (matches the repo's existing convention).
Tests
NetworkObservationTests: 5/5 passed, repeated runs.PacketArchiveTest: 14/14 passed, repeated runs.