generated from MetaMask/metamask-module-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Problem
When a connection is marked as permanently dead (no longer retrying), a user action that initiates a new connection to the same peer should:
- Clear the permanent failure state and allow the connection
- Use incarnation ID logic to detect if it's the same peer instance or a restarted peer
- React appropriately based on whether the incarnation changed
Current Gaps
sendRemoteMessage()doesn't clear permanent failure - if a user sends to a permanently-failed peer without callingreconnectPeer()first, the message will fail- Handshake not integrated into connection flow - handshake module exists (
handshake.ts) but channels are registered without exchanging incarnation IDs - No incarnation change callback - when incarnation changes (peer restarted),
RemoteHandlestate needs to be reset
Proposed Solution
Part 1: Clear Permanent Failure on User-Initiated Send
In sendRemoteMessage(), check and clear permanent failure before dialing.
Part 2: Integrate Handshake into Connection Flow
- Add
localIncarnationIdparameter toinitTransport() - Perform outbound/inbound handshake after channel establishment
- Pass handshake deps to reconnection lifecycle
Part 3: Add Incarnation Change Callback
- Add
OnIncarnationChangecallback type - In
RemoteHandle, addhandlePeerRestart()method to:- Reject all pending messages
- Reject pending URL redemptions
- Reset sequence numbers
- Clear persisted sequence state
Part 4: Same Incarnation (Resurrection)
No changes needed - normal operation continues with existing sequence numbers.
Files to Modify
packages/ocap-kernel/src/remotes/platform/transport.tspackages/ocap-kernel/src/remotes/platform/reconnection-lifecycle.tspackages/ocap-kernel/src/remotes/kernel/RemoteHandle.tspackages/ocap-kernel/src/remotes/kernel/RemoteManager.tspackages/ocap-kernel/src/remotes/types.tspackages/ocap-kernel/src/store/index.ts(may needclearRemoteSeqState())
Behavior Summary
| Scenario | Behavior |
|---|---|
| Send to permanently-failed peer | Clear failure, dial, handshake, proceed |
| Same incarnation ID | Normal operation, pending messages may still be ACKed |
| Different incarnation ID | Reset RemoteHandle state, reject pending, start fresh |
Metadata
Metadata
Assignees
Labels
No labels