Skip to content

Fix MeshCoreSession response and error miscorrelation#264

Merged
Avi0n merged 1 commit into
Avi0n:devfrom
robekl:fix/meshcore-session-response-correlation-squashed
Mar 23, 2026
Merged

Fix MeshCoreSession response and error miscorrelation#264
Avi0n merged 1 commit into
Avi0n:devfrom
robekl:fix/meshcore-session-response-correlation-squashed

Conversation

@robekl
Copy link
Copy Markdown
Contributor

@robekl robekl commented Mar 23, 2026

Summary

  • fix MeshCoreSession request/response miscorrelation for generic command responses, typed singleton responses, routed binary responses, and contact/private-key flows
  • keep unrelated responses from completing the wrong in-flight request
  • fail fast on request-specific device errors for binary requests
  • add regression coverage for the command-correlation cases exercised by the session APIs

Why this PR exists

This supersedes #261 as a single squashed commit per maintainer request.

The core issue is that several MeshCoreSession request paths were still accepting responses that matched too broadly:

  • generic OK/ERROR-style command waits could be satisfied by unrelated responses
  • typed singleton responses could be consumed by the wrong in-flight request
  • routed binary responses needed stronger node/type correlation
  • getContact(publicKey:) needed to ignore contacts for other keys rather than resolving early

This change tightens correlation without changing the public API shape.

Additional fix included

While validating the squashed branch, the new correlation test suite exposed a hang in the generic event-wait helpers when the timeout branch won the race. The waiting task could remain suspended on an AsyncStream subscription after timeout, which kept the test runner alive.

That is fixed here by explicitly finishing tracked event subscriptions in the generic wait helpers once a result, error, or timeout is decided.

Validation

  • swift test --package-path MeshCore --scratch-path /tmp/meshcoreone-pr261-squashed/.scratch-suite --filter MeshCoreSessionCommandCorrelationTests
  • swift test --package-path MeshCore --scratch-path /tmp/meshcoreone-pr261-squashed/.scratch-full

Results:

  • MeshCoreSessionCommandCorrelationTests: passed
  • MeshCore: 279 tests passed

Supersedes

@Avi0n
Copy link
Copy Markdown
Owner

Avi0n commented Mar 23, 2026

Thanks!

@Avi0n Avi0n merged commit 863bbf3 into Avi0n:dev Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants