@kontourai/survey 8.1.0 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,7 +65,12 @@ async function readSession(path) {
|
|
|
65
65
|
// ---------------------------------------------------------------------------
|
|
66
66
|
function createSseBroadcaster() {
|
|
67
67
|
const clients = new Set();
|
|
68
|
+
let closed = false;
|
|
68
69
|
function add(res) {
|
|
70
|
+
if (closed) {
|
|
71
|
+
res.end();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
69
74
|
clients.add(res);
|
|
70
75
|
res.on("close", () => clients.delete(res));
|
|
71
76
|
}
|
|
@@ -80,7 +85,13 @@ function createSseBroadcaster() {
|
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
|
-
|
|
88
|
+
function close() {
|
|
89
|
+
closed = true;
|
|
90
|
+
for (const res of clients)
|
|
91
|
+
res.end();
|
|
92
|
+
clients.clear();
|
|
93
|
+
}
|
|
94
|
+
return { add, broadcast, close };
|
|
84
95
|
}
|
|
85
96
|
// ---------------------------------------------------------------------------
|
|
86
97
|
// File watcher with debounce + polling fallback
|
|
@@ -802,12 +813,14 @@ export async function startReviewConsoleServer(options) {
|
|
|
802
813
|
listenPort = address.port;
|
|
803
814
|
const normalizedHost = host === "::1" ? "[::1]" : host;
|
|
804
815
|
const url = `http://${normalizedHost}:${address.port}/`;
|
|
816
|
+
let closing;
|
|
805
817
|
return {
|
|
806
818
|
url,
|
|
807
819
|
port: address.port,
|
|
808
820
|
host,
|
|
809
|
-
close: () => new Promise((resolveClosed, reject) => {
|
|
821
|
+
close: () => closing ??= new Promise((resolveClosed, reject) => {
|
|
810
822
|
stopWatcher();
|
|
823
|
+
broadcaster.close();
|
|
811
824
|
server.close((err) => (err ? reject(err) : resolveClosed()));
|
|
812
825
|
}),
|
|
813
826
|
};
|
package/package.json
CHANGED