Skip to content

Add opt-in interactive (WCSession.sendMessage) delivery path #23

Description

@leogdion

Background

MessageRouter.send(_:) (dictionary path) now always routes through
updateApplicationContext (serialized via a dedicated DispatchQueue), and the
interactive WCSession.sendMessage path was removed. See
Sources/SundialKitStream/MessageRouter.swift.

This is the correct default for the ContextEngine use case (latest-desired-state
snapshots, for which application context is correct in every reachability state)
and it sidesteps the double-resume crash a flapping link causes with
sendMessage's reply-expecting checked continuation.

The gap

Callers that previously relied on the low-latency interactive path
(ConnectivityObserver.sendMessage(_:) → WCSession.sendMessage when reachable)
no longer get immediate delivery — a time-critical command (e.g. "start workout
now") is now coalesced through application context. This is a silent behavioral
change with no compile-time signal.

Proposal

Offer an explicit opt-in for the interactive path for callers that genuinely need
immediate, reply-bearing delivery while reachable — e.g. a distinct API
(sendInteractive(_:)) or a transport option on the existing call — so the safe
application-context routing stays the default while low-latency delivery remains
available behind an explicit choice.

If we add it back, the implementation must guard the withCheckedThrowingContinuation
against a double-resume (a flapping link can fire sendMessage's error handler
twice), mirroring the ResumeOnce guard now used on the binary sendBinary path.

Context

Raised during the v1.0.0-alpha.3 PR review (finding F4). Deferred intentionally:
the current default is correct; this tracks the opt-out for interactive callers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions