Skip to content

Commit 8323837

Browse files
committed
close channel after dials
1 parent 799b1d3 commit 8323837

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

packages/ocap-kernel/src/remotes/network.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,20 @@ export async function initNetwork(
582582
`${targetPeerId}:: reconnection started during dial, queueing message ` +
583583
`(${queue.length}/${maxQueue}): ${message}`,
584584
);
585+
// Explicitly close the channel to release network resources
586+
// The reconnection loop will dial its own new channel
587+
await connectionFactory.closeChannel(channel, targetPeerId);
585588
return;
586589
}
587590

588591
// Check if a concurrent call already registered a channel for this peer
589592
// (dialIdempotent may return the same channel due to deduplication)
590593
const existingChannel = channels.get(targetPeerId);
591594
if (existingChannel) {
595+
// Close the dialed channel if it's different from the existing one
596+
if (channel !== existingChannel) {
597+
await connectionFactory.closeChannel(channel, targetPeerId);
598+
}
592599
// Another concurrent call already registered the channel, use it
593600
channel = existingChannel;
594601
} else {

vitest.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default defineConfig({
106106
'packages/kernel-platforms/**': {
107107
statements: 99.38,
108108
functions: 100,
109-
branches: 96.2,
109+
branches: 96.25,
110110
lines: 99.38,
111111
},
112112
'packages/kernel-rpc-methods/**': {
@@ -130,7 +130,7 @@ export default defineConfig({
130130
'packages/kernel-ui/**': {
131131
statements: 97.57,
132132
functions: 97.29,
133-
branches: 93.26,
133+
branches: 93.25,
134134
lines: 97.57,
135135
},
136136
'packages/kernel-utils/**': {
@@ -158,10 +158,10 @@ export default defineConfig({
158158
lines: 22.22,
159159
},
160160
'packages/ocap-kernel/**': {
161-
statements: 96.45,
161+
statements: 96.42,
162162
functions: 98.56,
163-
branches: 97.34,
164-
lines: 96.45,
163+
branches: 97.27,
164+
lines: 96.42,
165165
},
166166
'packages/omnium-gatherum/**': {
167167
statements: 5.67,

0 commit comments

Comments
 (0)