fix(node): expose subscriptions on ClientNodeInteraction wrapper#3694
Merged
fix(node): expose subscriptions on ClientNodeInteraction wrapper#3694
Conversation
CommissioningClient assigns `node.interaction as ClientInteraction` to `peer.interaction`, but `node.interaction` is a `ClientNodeInteraction` wrapper that did not expose `subscriptions`. PeerAddressMonitor's address-migration path then dereferenced `interaction.subscriptions`, crashing with "Cannot read properties of undefined (reading 'closeForPeer')" whenever a session migrated to a discovered IP. Add a `subscriptions` getter on `ClientNodeInteraction` that resolves the singleton from the node environment, matching what the inner `ClientInteraction` returns. Tighten `ClientInteraction.environment` from `protected` to `#environment` since no subclass needs it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime crash during successful peer address migration by ensuring the ClientNodeInteraction wrapper exposes the subscriptions API expected by PeerAddressMonitor, and slightly refactors ClientInteraction’s environment storage.
Changes:
- Expose
subscriptionsonClientNodeInteractionby resolvingClientSubscriptionsfrom the node environment. - Refactor
ClientInteractionto storeEnvironmentin a private#environmentfield and use it for lazyClientSubscriptionsresolution.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/protocol/src/action/client/ClientInteraction.ts | Makes the environment reference private and updates lazy ClientSubscriptions initialization to use it. |
| packages/node/src/node/client/ClientNodeInteraction.ts | Adds a subscriptions getter so the wrapper matches the runtime expectations of peer address migration logic. |
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
CommissioningClientcastsnode.interactiontoClientInteractionand assigns it topeer.interaction, but the runtime value is aClientNodeInteractionwrapper which did not exposesubscriptions.PeerAddressMonitorcrashed atinteraction.subscriptions.closeForPeer(...)whenever an address migration succeeded.subscriptionsgetter onClientNodeInteractionthat resolvesClientSubscriptionsfrom the node environment — same singleton the innerClientInteractionwould return, without forcing lazy interactable creation.ClientInteraction.environmentfromprotectedto#environmentsince no subclass needs it.Observed crash:
🤖 Generated with Claude Code