Skip to content

fix(node): expose subscriptions on ClientNodeInteraction wrapper#3694

Merged
Apollon77 merged 1 commit intomainfrom
check-error-tostring
May 6, 2026
Merged

fix(node): expose subscriptions on ClientNodeInteraction wrapper#3694
Apollon77 merged 1 commit intomainfrom
check-error-tostring

Conversation

@Apollon77
Copy link
Copy Markdown
Collaborator

@Apollon77 Apollon77 commented May 6, 2026

Summary

  • CommissioningClient casts node.interaction to ClientInteraction and assigns it to peer.interaction, but the runtime value is a ClientNodeInteraction wrapper which did not expose subscriptions. PeerAddressMonitor crashed at interaction.subscriptions.closeForPeer(...) whenever an address migration succeeded.
  • Add a subscriptions getter on ClientNodeInteraction that resolves ClientSubscriptions from the node environment — same singleton the inner ClientInteraction would return, without forcing lazy interactable creation.
  • Tighten ClientInteraction.environment from protected to #environment since no subclass needs it.

Observed crash:

ERROR  Multiplex            Error: Cannot read properties of undefined (reading 'closeForPeer')
  at PeerAddressMonitor.#check (packages/protocol/src/peer/PeerAddressMonitor.ts:186:43)

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 6, 2026 09:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 subscriptions on ClientNodeInteraction by resolving ClientSubscriptions from the node environment.
  • Refactor ClientInteraction to store Environment in a private #environment field and use it for lazy ClientSubscriptions resolution.

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.

Comment thread packages/protocol/src/action/client/ClientInteraction.ts
Comment thread packages/node/src/node/client/ClientNodeInteraction.ts
@Apollon77 Apollon77 merged commit ccd892f into main May 6, 2026
42 checks passed
@Apollon77 Apollon77 deleted the check-error-tostring branch May 6, 2026 11:01
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