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

Revert "Fix handling of error status of a workspace " #13699

Merged
merged 1 commit into from
Jul 4, 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
25 changes: 17 additions & 8 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';

export enum MasterChannels {
enum MasterChannels {
ENVIRONMENT_OUTPUT = 'runtime/log',
ENVIRONMENT_STATUS = 'machine/statusChanged',
INSTALLER_OUTPUT = 'installer/log',
Expand All @@ -25,6 +25,13 @@ export 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 @@ -98,12 +105,12 @@ export class CheJsonRpcMasterApi {
*
* @returns {Promise<void>}
*/
async connect(): Promise<void> {
connect(): Promise<void> {
const entryPointFunction = () => {
const entryPoint = this.entryPoint + this.loader.getAuthenticationToken();
if (this.clientId) {
let clientId = `clientId=${this.clientId}`;
// in case of re-connection
// in case of reconnection
// we need to test entrypoint on existing query parameters
// to add already gotten clientId
if (/\?/.test(entryPoint) === false) {
Expand All @@ -116,8 +123,9 @@ export class CheJsonRpcMasterApi {
return entryPoint;
};

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

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

/**
Expand Down
Loading