From 7e495f037b3a9ed6eb64b1e63bf4ddb08b78866f Mon Sep 17 00:00:00 2001 From: Baptiste Clarey Sjostrand <112877883+baphony@users.noreply.github.com> Date: Tue, 14 Mar 2023 12:58:48 +0100 Subject: [PATCH] RTC-13903 Fix C9 process restarting loop (#1770) When C9 process starts, sometimes we get a 'no connection' message, then a 'connection available' which triggers the c9 process restart. --- src/app/c9-shell-handler.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/c9-shell-handler.ts b/src/app/c9-shell-handler.ts index 0391db570..a1d6401eb 100644 --- a/src/app/c9-shell-handler.ts +++ b/src/app/c9-shell-handler.ts @@ -20,6 +20,7 @@ class C9ShellHandler { private _c9shell: ChildProcess | undefined; private _curStatus: IShellStatus | undefined; private _isDisconnected = false; + private _isFreshStart = true; private _isStarting = false; private _isTerminating = false; private _sender: WebContents; @@ -195,6 +196,7 @@ class C9ShellHandler { ); this._updateStatus({ status: 'starting' }); + this._isFreshStart = true; const c9Shell = spawn(c9ShellPath, customC9ShellArgList, { stdio: 'pipe' }); c9Shell.on('close', (code) => { @@ -234,10 +236,11 @@ class C9ShellHandler { * @param c9ShellMessage Any message provided by c9-shell */ private _updateNetworkStatus(c9ShellMessage: string) { - if (this._isDisconnected) { - if ( - c9ShellMessage.includes('NetworkConnectivityService|Internet Available') - ) { + if ( + c9ShellMessage.includes('NetworkConnectivityService|Internet Available') + ) { + this._isFreshStart = false; + if (this._isDisconnected) { this._isDisconnected = false; this._onNetworkReconnection(); } @@ -246,7 +249,7 @@ class C9ShellHandler { 'NetworkConnectivityService|No Internet Available', ) ) { - this._isDisconnected = true; + this._isDisconnected = !this._isFreshStart; } }