()
| 1354 | } |
| 1355 | |
| 1356 | async _getHubMailboxStatus() { |
| 1357 | if (!this.hubUrl) return { error: 'Hub not configured' }; |
| 1358 | const nodeId = this.lifecycle.nodeId; |
| 1359 | if (!nodeId) return { error: 'No node_id yet' }; |
| 1360 | const endpoint = `${this.hubUrl}/a2a/mailbox/status?node_id=${encodeURIComponent(nodeId)}`; |
| 1361 | try { |
| 1362 | const res = await hubFetch(endpoint, { |
| 1363 | method: 'GET', |
| 1364 | headers: this.lifecycle._buildHeaders(), |
| 1365 | signal: AbortSignal.timeout(10_000), |
| 1366 | }); |
| 1367 | if (!res.ok) { |
| 1368 | // Drain body so undici can recycle the socket back to the pool. |
| 1369 | // Without this, repeated non-ok responses leak pool slots and |
| 1370 | // eventually starve the dispatcher. |
| 1371 | try { res.body?.cancel?.().catch(() => {}); } catch {} |
| 1372 | return { error: `Hub ${res.status}` }; |
| 1373 | } |
| 1374 | return res.json(); |
| 1375 | } catch (err) { |
| 1376 | return { error: err.message }; |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | async function startProxy(opts = {}) { |
no test coverage detected