From 2a533d6f7fb407dd5166dbeadfad8e627d849b20 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 16 Feb 2023 21:40:40 -0500 Subject: [PATCH] *If the dht closes, then remove the connection handler and emit the close event on the swarm --- src/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/index.ts b/src/index.ts index 7f869a9..6af6681 100644 --- a/src/index.ts +++ b/src/index.ts @@ -317,6 +317,12 @@ async function handleListenConnections(aq: ActiveQuery) { swarm.off("connection", listener); aq.respond(); }); + + swarm.activeRelay.dht.one("close", () => { + swarm.off("connection", listener); + swarm.emit("close"); + aq.respond(); + }); } async function handleGetSocketInfo(aq: ActiveQuery) {