From acc246153e39eba0be71714f45e347e154a76ab0 Mon Sep 17 00:00:00 2001 From: Martyn Janes Date: Fri, 12 Jan 2024 12:54:34 +0200 Subject: [PATCH] Handle launch websocket disconnect --- how-to/container-platform-starter/scripts/launch.mjs | 8 +++++++- how-to/create-window/scripts/launch.mjs | 8 +++++++- how-to/integration-excel/scripts/launch.mjs | 8 +++++++- .../create-a-single-page-platform/scripts/launch.mjs | 8 +++++++- .../issue-commands-to-a-platform/scripts/launch.mjs | 8 +++++++- how-to/use-content-creation-rules/scripts/launch.mjs | 8 +++++++- how-to/use-dynamic-manifest/basic/scripts/launch.mjs | 8 +++++++- .../setup-multi-platform-interop/scripts/launch.mjs | 8 +++++++- how-to/use-launch-external-process/scripts/launch.mjs | 8 +++++++- how-to/use-logging-apis/scripts/launch.mjs | 8 +++++++- .../warn-before-closing-dialog/scripts/launch.mjs | 8 +++++++- how-to/use-popup-window/advanced/scripts/launch.mjs | 8 +++++++- how-to/use-popup-window/modal/scripts/launch.mjs | 8 +++++++- .../use-popup-window/multiple-results/scripts/launch.mjs | 8 +++++++- how-to/use-popup-window/single-result/scripts/launch.mjs | 8 +++++++- how-to/use-preloads/basic/scripts/launch.mjs | 8 +++++++- how-to/use-preloads/restart-on-refresh/scripts/launch.mjs | 8 +++++++- how-to/use-security-realms/scripts/launch.mjs | 8 +++++++- how-to/use-window-options/scripts/launch.mjs | 8 +++++++- 19 files changed, 133 insertions(+), 19 deletions(-) diff --git a/how-to/container-platform-starter/scripts/launch.mjs b/how-to/container-platform-starter/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/container-platform-starter/scripts/launch.mjs +++ b/how-to/container-platform-starter/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/create-window/scripts/launch.mjs b/how-to/create-window/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/create-window/scripts/launch.mjs +++ b/how-to/create-window/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/integration-excel/scripts/launch.mjs b/how-to/integration-excel/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/integration-excel/scripts/launch.mjs +++ b/how-to/integration-excel/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-a-manifest/create-a-single-page-platform/scripts/launch.mjs b/how-to/use-a-manifest/create-a-single-page-platform/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-a-manifest/create-a-single-page-platform/scripts/launch.mjs +++ b/how-to/use-a-manifest/create-a-single-page-platform/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-channel-api/issue-commands-to-a-platform/scripts/launch.mjs b/how-to/use-channel-api/issue-commands-to-a-platform/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-channel-api/issue-commands-to-a-platform/scripts/launch.mjs +++ b/how-to/use-channel-api/issue-commands-to-a-platform/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-content-creation-rules/scripts/launch.mjs b/how-to/use-content-creation-rules/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-content-creation-rules/scripts/launch.mjs +++ b/how-to/use-content-creation-rules/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-dynamic-manifest/basic/scripts/launch.mjs b/how-to/use-dynamic-manifest/basic/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-dynamic-manifest/basic/scripts/launch.mjs +++ b/how-to/use-dynamic-manifest/basic/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-interop/setup-multi-platform-interop/scripts/launch.mjs b/how-to/use-interop/setup-multi-platform-interop/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-interop/setup-multi-platform-interop/scripts/launch.mjs +++ b/how-to/use-interop/setup-multi-platform-interop/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-launch-external-process/scripts/launch.mjs b/how-to/use-launch-external-process/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-launch-external-process/scripts/launch.mjs +++ b/how-to/use-launch-external-process/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-logging-apis/scripts/launch.mjs b/how-to/use-logging-apis/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-logging-apis/scripts/launch.mjs +++ b/how-to/use-logging-apis/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-platform/warn-before-closing-dialog/scripts/launch.mjs b/how-to/use-platform/warn-before-closing-dialog/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-platform/warn-before-closing-dialog/scripts/launch.mjs +++ b/how-to/use-platform/warn-before-closing-dialog/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-popup-window/advanced/scripts/launch.mjs b/how-to/use-popup-window/advanced/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-popup-window/advanced/scripts/launch.mjs +++ b/how-to/use-popup-window/advanced/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-popup-window/modal/scripts/launch.mjs b/how-to/use-popup-window/modal/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-popup-window/modal/scripts/launch.mjs +++ b/how-to/use-popup-window/modal/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-popup-window/multiple-results/scripts/launch.mjs b/how-to/use-popup-window/multiple-results/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-popup-window/multiple-results/scripts/launch.mjs +++ b/how-to/use-popup-window/multiple-results/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-popup-window/single-result/scripts/launch.mjs b/how-to/use-popup-window/single-result/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-popup-window/single-result/scripts/launch.mjs +++ b/how-to/use-popup-window/single-result/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-preloads/basic/scripts/launch.mjs b/how-to/use-preloads/basic/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-preloads/basic/scripts/launch.mjs +++ b/how-to/use-preloads/basic/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-preloads/restart-on-refresh/scripts/launch.mjs b/how-to/use-preloads/restart-on-refresh/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-preloads/restart-on-refresh/scripts/launch.mjs +++ b/how-to/use-preloads/restart-on-refresh/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-security-realms/scripts/launch.mjs b/how-to/use-security-realms/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-security-realms/scripts/launch.mjs +++ b/how-to/use-security-realms/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`); diff --git a/how-to/use-window-options/scripts/launch.mjs b/how-to/use-window-options/scripts/launch.mjs index ac38f6c3..fd08a2a4 100644 --- a/how-to/use-window-options/scripts/launch.mjs +++ b/how-to/use-window-options/scripts/launch.mjs @@ -31,7 +31,13 @@ async function run(manifestUrl) { await platform.quit(); } } catch (err) { - console.error(err); + if (err.toString().includes('no longer connected')) { + console.log('Platform no longer connected'); + console.log('Exiting process'); + process.exit(); + } else { + console.error(err); + } } }; console.log(`Wrapped target platform: ${manifest.platform.uuid}`);