Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of error status of a workspace #13804

Merged
merged 3 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspace-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "jest",
"test:watch": "jest --watch",
"compile": "webpack --config webpack.prod.js",
"start": "webpack-dev-server --open --config webpack.dev.js",
"start": "webpack-dev-server --open --disable-host-check --config webpack.dev.js",
"format": "tsfmt -r --useTsfmt tsfmt.json",
"lint:fix": "tslint -c tslint.json --fix --project .",
"build": "yarn run format && yarn run compile"
Expand Down
25 changes: 8 additions & 17 deletions workspace-loader/src/json-rpc/che-json-rpc-master-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { CheJsonRpcApiClient } from './che-json-rpc-api-service';
import { ICommunicationClient, CODE_REQUEST_TIMEOUT, CommunicationClientEvent } from './json-rpc-client';
import { WorkspaceLoader } from '../workspace-loader';

enum MasterChannels {
export enum MasterChannels {
ENVIRONMENT_OUTPUT = 'runtime/log',
ENVIRONMENT_STATUS = 'machine/statusChanged',
INSTALLER_OUTPUT = 'installer/log',
Expand All @@ -25,13 +25,6 @@ enum MasterChannels {
const SUBSCRIBE: string = 'subscribe';
const UNSUBSCRIBE: string = 'unsubscribe';

export interface WorkspaceStatusChangedEvent {
status: string;
prevStatus: string;
workspaceId: string;
error: string;
}

/**
* Client API for workspace master interactions.
*
Expand Down Expand Up @@ -105,12 +98,12 @@ export class CheJsonRpcMasterApi {
*
* @returns {Promise<void>}
*/
connect(): Promise<void> {
async connect(): Promise<void> {
const entryPointFunction = () => {
const entryPoint = this.entryPoint + this.loader.getAuthenticationToken();
if (this.clientId) {
let clientId = `clientId=${this.clientId}`;
// in case of reconnection
// in case of re-connection
// we need to test entrypoint on existing query parameters
// to add already gotten clientId
if (/\?/.test(entryPoint) === false) {
Expand All @@ -123,9 +116,8 @@ export class CheJsonRpcMasterApi {
return entryPoint;
};

return this.cheJsonRpcApi.connect(entryPointFunction).then(() =>
this.fetchClientId()
);
await this.cheJsonRpcApi.connect(entryPointFunction);
return await this.fetchClientId();
}

/**
Expand Down Expand Up @@ -220,10 +212,9 @@ export class CheJsonRpcMasterApi {
*
* @returns {Promise<void>}
*/
fetchClientId(): Promise<void> {
return this.cheJsonRpcApi.request('websocketIdService/getId').then((data: string[]) => {
this.clientId = data[0];
});
async fetchClientId(): Promise<void> {
const data = await this.cheJsonRpcApi.request('websocketIdService/getId');
this.clientId = data[0];
}

/**
Expand Down
Loading