openzca 0.1.18 → 0.1.19
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/dist/cli.js +27 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -831,6 +831,30 @@ async function withTimeout(task, timeoutMs, message) {
|
|
|
831
831
|
if (timeoutId) clearTimeout(timeoutId);
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
+
async function stopUploadListenerSafely(api, command, waitClosedMs = 1500) {
|
|
835
|
+
await new Promise((resolve) => {
|
|
836
|
+
let settled = false;
|
|
837
|
+
let timeoutId;
|
|
838
|
+
const finish = () => {
|
|
839
|
+
if (settled) return;
|
|
840
|
+
settled = true;
|
|
841
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
842
|
+
api.listener.off("closed", onClosed);
|
|
843
|
+
resolve();
|
|
844
|
+
};
|
|
845
|
+
const onClosed = () => {
|
|
846
|
+
finish();
|
|
847
|
+
};
|
|
848
|
+
api.listener.on("closed", onClosed);
|
|
849
|
+
timeoutId = setTimeout(finish, waitClosedMs);
|
|
850
|
+
try {
|
|
851
|
+
api.listener.stop();
|
|
852
|
+
writeDebugLine("msg.upload.listener.stop", void 0, command);
|
|
853
|
+
} catch {
|
|
854
|
+
finish();
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
}
|
|
834
858
|
async function withUploadListener(api, command, task) {
|
|
835
859
|
const connectTimeoutMs = parsePositiveIntFromEnv(
|
|
836
860
|
"OPENZCA_UPLOAD_LISTENER_CONNECT_TIMEOUT_MS",
|
|
@@ -928,15 +952,11 @@ async function withUploadListener(api, command, task) {
|
|
|
928
952
|
`Timed out waiting ${uploadTimeoutMs}ms for file upload completion.`
|
|
929
953
|
);
|
|
930
954
|
} finally {
|
|
931
|
-
api.listener.off("error", sinkError);
|
|
932
|
-
api.listener.off("closed", sinkClosed);
|
|
933
955
|
if (startedHere) {
|
|
934
|
-
|
|
935
|
-
api.listener.stop();
|
|
936
|
-
writeDebugLine("msg.upload.listener.stop", void 0, command);
|
|
937
|
-
} catch {
|
|
938
|
-
}
|
|
956
|
+
await stopUploadListenerSafely(api, command);
|
|
939
957
|
}
|
|
958
|
+
api.listener.off("error", sinkError);
|
|
959
|
+
api.listener.off("closed", sinkClosed);
|
|
940
960
|
}
|
|
941
961
|
}
|
|
942
962
|
async function fetchRecentMessagesViaListener(api, threadId, threadType, count) {
|