Skip to content

Commit

Permalink
Fix handling of error status of a workspace (#13804)
Browse files Browse the repository at this point in the history
* fixed handling of error status of a workspace after it has been started.

Signed-off-by: Oleksii Kurinnyi <[email protected]>

* workaround for devserver proxy to replace header 'origin' with target host

Signed-off-by: Oleksii Kurinnyi <[email protected]>

* use string interpolation instead of concatenation

Signed-off-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
akurinnoy authored Sep 5, 2019
1 parent 9072be9 commit 208c4fb
Show file tree
Hide file tree
Showing 5 changed files with 599 additions and 605 deletions.
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

0 comments on commit 208c4fb

Please sign in to comment.