wispjs 3.0.0 → 3.0.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.
- package/dist/wisp_socket/index.js +16 -2
- package/package.json +1 -1
|
@@ -220,8 +220,13 @@ export class WispSocket {
|
|
|
220
220
|
const logger = worker.logger;
|
|
221
221
|
logger.log("Running setupConsoleListener");
|
|
222
222
|
return new Promise((resolve) => {
|
|
223
|
-
|
|
223
|
+
const cleanup = () => {
|
|
224
|
+
worker.socket.off("console output", handleLine);
|
|
225
|
+
worker.socket.off("disconnect", handleDisconnect);
|
|
226
|
+
};
|
|
227
|
+
const handleLine = (line) => {
|
|
224
228
|
if (this.consoleCallbacks.length == 0) {
|
|
229
|
+
cleanup();
|
|
225
230
|
return resolve();
|
|
226
231
|
}
|
|
227
232
|
this.consoleCallbacks.forEach((callback) => {
|
|
@@ -232,7 +237,16 @@ export class WispSocket {
|
|
|
232
237
|
logger.error("Failed to run console callback", e);
|
|
233
238
|
}
|
|
234
239
|
});
|
|
235
|
-
}
|
|
240
|
+
};
|
|
241
|
+
const handleDisconnect = () => {
|
|
242
|
+
cleanup();
|
|
243
|
+
resolve();
|
|
244
|
+
if (this.consoleCallbacks.length > 0) {
|
|
245
|
+
this.setupConsoleListener();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
worker.socket.on("console output", handleLine);
|
|
249
|
+
worker.socket.once("disconnect", handleDisconnect);
|
|
236
250
|
});
|
|
237
251
|
});
|
|
238
252
|
});
|