Skip to content

Commit

Permalink
RTC-13903 Fix C9 process restarting loop (#1770)
Browse files Browse the repository at this point in the history
When C9 process starts, sometimes we get a 'no connection' message,
then a 'connection available' which triggers the c9 process restart.
  • Loading branch information
baphony authored Mar 14, 2023
1 parent f8db9e5 commit 7e495f0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/app/c9-shell-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -195,6 +196,7 @@ class C9ShellHandler {
);

this._updateStatus({ status: 'starting' });
this._isFreshStart = true;
const c9Shell = spawn(c9ShellPath, customC9ShellArgList, { stdio: 'pipe' });

c9Shell.on('close', (code) => {
Expand Down Expand Up @@ -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();
}
Expand All @@ -246,7 +249,7 @@ class C9ShellHandler {
'NetworkConnectivityService|No Internet Available',
)
) {
this._isDisconnected = true;
this._isDisconnected = !this._isFreshStart;
}
}

Expand Down

0 comments on commit 7e495f0

Please sign in to comment.