Fix MeshCoreSession response and error miscorrelation#261
Closed
robekl wants to merge 8 commits into
Closed
Conversation
Avi0n
reviewed
Mar 18, 2026
Avi0n
reviewed
Mar 19, 2026
Owner
|
Nice, thank you. Since this one has quite a few commits, could you squash them for me? Just to make the git history look a little cleaner. |
Contributor
Author
|
Superseded by #264, which contains the same MeshCoreSession correlation fix as a single squashed commit plus the event-wait subscription hang fix found during validation. |
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.
Summary
This PR fixes
MeshCoreSessionrequest/response miscorrelation by tightening how active commands accept success and error events.The implementation is organized as a small series:
MeshCoreSessiondocs with response matchingWhat changed
.ok/.errorevents.errorevents as belonging to the active request in generic and typed request pathsgetContact(publicKey:)to match the requested public keyimportPrivateKey(_)to accept only bare.ok(nil)as success.errorso an early rejection cannot stall the binary request serializerdefer { release() }Notes on scope
A few APIs are still only serialized rather than fully correlated because the wire protocol does not expose enough identity to distinguish an unsolicited same-type event from the intended response. This PR only fixes the cases that can be made correct without inventing protocol semantics.
Binary requests intentionally remain a separate class from generic typed waits: they still fail immediately on device
.error, because ignoring that event can strand the serialized binary request pipeline.Tests
Added or updated regression coverage in
MeshCoreSessionCommandCorrelationTestsfor:.okresponses with payloads for simple commands.errorduringstart()andgetBattery()channelInfocontact.ok(value:)duringimportPrivateKey.errorbeforemessageSentValidation run on the branch:
cd MeshCore && swift testcd MC1Services && swift testxcodebuild -project MC1.xcodeproj -scheme MC1 -destination "platform=iOS Simulator,name=iPhone 16e" testLatest binary-request follow-up additionally revalidated with:
cd MeshCore && swift test --filter MeshCoreSessionCommandCorrelationTestscd MC1Services && swift test