New logic for establishing client connections#3131
Draft
lauckhart wants to merge 10 commits intomatter-js:mainfrom
Draft
New logic for establishing client connections#3131lauckhart wants to merge 10 commits intomatter-js:mainfrom
lauckhart wants to merge 10 commits intomatter-js:mainfrom
Conversation
b58e583 to
a91e492
Compare
Apollon77
reviewed
Feb 3, 2026
| const session = await this.#peer.connect(options); | ||
|
|
||
| const network = this.#context.networks.select(this.#peer, options?.network); | ||
| const slot = await network.semaphore.obtainSlot(abort); |
Collaborator
There was a problem hiding this comment.
can we get some kinda of network info somehow into the log also at least on level of exchange creation or logging ... would potentially be easier for debugging
Collaborator
Author
There was a problem hiding this comment.
You mean specifically relating to semaphore slots held or something more general?
For semaphore specifically dedicated messages seem noisy but maybe we could log "slow acquisition" similar to how we handle transactions
618d55a to
a71a817
Compare
Most of this will be difficult to separate into separate commits so will likely need a "big bang" merge. And is maybe best considered "unreviewable" 🙄.
In addition to inevitable bugs this commit does not address legacy codepaths and thus leaves a large amount of deprecated code in place.
Overview:
* Adds `PeerConnection` function that performs Peer (re-)connection. This implements new connection logic we've discussed and isolates relevant state to a single closure.
* Other relevant bits include `Peer.connect()` and `PeerExchangeProvider`.
* Numerous changes to existing `@matter/protocol` components in support of above. I tried to keep these changes minimal but the diffs end up pretty horrendous... Mostly this deals with new options
* Adds additional information to `PeerDescriptor`, improves logic for reacting to descriptor changes, and now uses a partial descriptor to add/configure peers
* Adds optional access to `Interactable` and `NodeProtocol` via `Peer` class. This makes generic access to Peer features (e.g. reading Basic Information attributes) from @node/protocol more straightforward
* Improves `ActionContext` and constituent interfaces to make them more useful in a client context. For example you can now do e.g. `toggle(undefined, { abort })` to make an invoke abortable
* Adds `NetworkProfiles` to manage semaphores associated with network access, identified by a string name
* Adds configurability to MRP handling to support new connection logic (namely, maximum backoff time and maximum number of retries)
* Moves some logic generic logic from `@matter/node` to `@matter/protocol`
* Changes lifecycle management of some dependencies of `@matter/node` to align them with the `ServerNode` instead of `ServerNetworkRuntime`
* Various other updates to `@matter/node` involve movement to `@matter/protocol` code paths, but there are also various general improvements to issues I encountered along the way
* Adds `PeerTimingParameters` to control new connection logic
* Makes more operations abortable
* Improves `PeerAddress` interning and `ClientNode#peerAddress` management
* Considerable rework of network error handling to improve naming and consistency
Fixes commissioning with CommissioningController
* Make mock IP address smaller ("abcd::1" vs "1111:2222:3333:4444:5555:6666:7777:8801")
* Fix "await abort" when `Abort` is already aborted
* Reduce mock time resolution interval in OtaTest and a ClientNode test to eliminate intermittent failures
* Reduce OtaTest mock firmware size
* Enable entropy for `MockSite` by default so we don't need to special-case everywhere that pairs (which requires entropy for ephemeral node ID generation)
* Add detailed logging for each connection attempt for each address
* Add the exchange's `via` to various log messages that had little context otherwise
* Fix a couple of errors from last merge
* Do not store resumption records when SessionManager closes; they're stored when changed and this allows storage to close before SessionManager (which otherwise caused errors in log)
* Log more CASE client errors caused by issues outside of our control without stack traces
Additional error handling to avoid crashing when generating diagnostics for an endpoint that is in a bad state.
335efc9 to
6e0eed5
Compare
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.
Most of this will be difficult to separate into separate commits so will likely need a "big bang" merge. And is maybe best considered "unreviewable" 🙄.
In addition to inevitable bugs this commit does not address legacy codepaths and thus leaves a large amount of deprecated code in place.
Overview:
Adds
PeerConnectionfunction that performs Peer (re-)connection. This implements new connection logic we've discussed and isolates relevant state to a single closure.Other relevant bits include
Peer.connect()andPeerExchangeProvider.Numerous changes to existing
@matter/protocolcomponents in support of above. I tried to keep these changes minimal but the diffs end up pretty horrendous... Mostly this deals with new optionsAdds additional information to
PeerDescriptor, improves logic for reacting to descriptor changes, and now uses a partial descriptor to add/configure peersAdds optional access to
InteractableandNodeProtocolviaPeerclass. This makes generic access to Peer features (e.g. reading Basic Information attributes) from @node/protocol more straightforwardImproves
ActionContextand constituent interfaces to make them more useful in a client context. For example you can now do e.g.toggle(undefined, { abort })to make an invoke abortableAdds
NetworkProfilesto manage semaphores associated with network access, identified by a string nameAdds configurability to MRP handling to support new connection logic (namely, maximum backoff time and maximum number of retries)
Moves some logic generic logic from
@matter/nodeto@matter/protocolChanges lifecycle management of some dependencies of
@matter/nodeto align them with theServerNodeinstead ofServerNetworkRuntimeVarious other updates to
@matter/nodeinvolve movement to@matter/protocolcode paths, but there are also various general improvements to issues I encountered along the wayAdds
PeerTimingParametersto control new connection logicMakes more operations abortable
Improves
PeerAddressinterning andClientNode#peerAddressmanagementConsiderable rework of network error handling to improve naming and consistency