@triflux/remote 10.29.0 → 10.30.0
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.
- package/hub/team/synapse-http.mjs +12 -7
- package/package.json +1 -1
|
@@ -124,13 +124,18 @@ export function drainPendingSynapse(timeoutMs = 1000) {
|
|
|
124
124
|
const settled = Promise.allSettled([...inFlightSynapse]);
|
|
125
125
|
const ms = Number(timeoutMs);
|
|
126
126
|
if (!Number.isFinite(ms) || ms <= 0) return settled;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
let timeout = null;
|
|
128
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
129
|
+
// Keep this timer ref'ed: drainPendingSynapse() is awaited specifically
|
|
130
|
+
// to hold the process open until either in-flight POSTs settle or the
|
|
131
|
+
// bounded drain budget expires. An unref'ed timer can let Node's test
|
|
132
|
+
// runner/process exit before the Promise resolves when no other handles
|
|
133
|
+
// remain.
|
|
134
|
+
timeout = setTimeout(resolve, ms);
|
|
135
|
+
});
|
|
136
|
+
return Promise.race([settled, timeoutPromise]).finally(() => {
|
|
137
|
+
if (timeout) clearTimeout(timeout);
|
|
138
|
+
});
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
export function registerSynapseSession(meta, opts = {}) {
|