(
pipeName: string,
machineId: string,
store: StoreApi,
disposed: { current: boolean },
)
| 270 | // --------------------------------------------------------------------------- |
| 271 | |
| 272 | function runMainHeartbeat( |
| 273 | pipeName: string, |
| 274 | machineId: string, |
| 275 | store: StoreApi, |
| 276 | disposed: { current: boolean }, |
| 277 | ): void { |
| 278 | void (async () => { |
| 279 | try { |
| 280 | await pr.cleanupStaleEntries() |
| 281 | const aliveSubs = await pr.getAliveSubs() |
| 282 | refreshDiscoveredPipes(pipeName, aliveSubs, store) |
| 283 | |
| 284 | const connectedSlaves = mm.getAllSlaveClients() |
| 285 | const aliveSubNames = new Set(aliveSubs.map(sub => sub.pipeName)) |
| 286 | |
| 287 | // Build unified attach target list: local subs + LAN peers |
| 288 | type AttachTarget = { |
| 289 | pipeName: string |
| 290 | tcpEndpoint?: { host: string; port: number } |
| 291 | } |
| 292 | const attachTargets: AttachTarget[] = aliveSubs.map(sub => ({ |
| 293 | pipeName: sub.pipeName, |
| 294 | })) |
| 295 | |
| 296 | // Add LAN peers as attach targets |
| 297 | if (feature('LAN_PIPES')) { |
| 298 | const beacon = lb.getLanBeacon() |
| 299 | if (beacon) { |
| 300 | const localNames = new Set(attachTargets.map(t => t.pipeName)) |
| 301 | localNames.add(pipeName) |
| 302 | for (const [pName, peer] of beacon.getPeers()) { |
| 303 | if (!localNames.has(pName)) { |
| 304 | attachTargets.push({ |
| 305 | pipeName: pName, |
| 306 | tcpEndpoint: { host: peer.ip, port: peer.tcpPort }, |
| 307 | }) |
| 308 | aliveSubNames.add(pName) |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | const currentPipeState = pt.getPipeIpc(store.getState()) |
| 315 | |
| 316 | for (const target of attachTargets) { |
| 317 | if (target.pipeName === pipeName) continue |
| 318 | if (connectedSlaves.has(target.pipeName)) continue |
| 319 | |
| 320 | try { |
| 321 | const myName = currentPipeState.serverName ?? pipeName |
| 322 | const client = await pt.connectToPipe( |
| 323 | target.pipeName, |
| 324 | myName, |
| 325 | 3000, |
| 326 | target.tcpEndpoint, |
| 327 | ) |
| 328 | |
| 329 | const attached = await new Promise<boolean>(resolve => { |
no test coverage detected