Added recreation check: Before creating a missing channel, the code now checks isRecreating(pluginDomain, protocol, peerId) to prevent duplicate creation attempts

This commit is contained in:
Raven Scott
2025-12-21 07:52:38 -05:00
parent 8a14e33bad
commit 7ec24c8122
+6
View File
@@ -1305,6 +1305,12 @@ function performHealthCheck() {
for (const [protocol, channelInfo] of protocolMap.entries()) {
const peerChannel = channelInfo.peerChannels?.get(peerId);
if (!peerChannel) {
// Check if this channel is currently being recreated to prevent loops
if (isRecreating(pluginDomain, protocol, peerId)) {
logDebug('ChannelManager', `Channel ${pluginDomain}-${protocol} for peer ${peerId.substring(0, 16)}... is already being recreated, skipping health check creation`);
continue;
}
// Peer is connected but missing this channel - create it
const isReconnection = state.peerHistory?.get(peerId)?.some(event => event.type === 'connect') || false;
const reconnectionNote = isReconnection ? ' (reconnection)' : '';