Skip to content

Commit 990ae06

Browse files
committed
💄
1 parent fbe43ad commit 990ae06

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/common/utils.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,20 @@ export function getServiceURL(gitpodHost: string): string {
115115
}
116116

117117
export class WrapError extends Error {
118-
code: string | undefined;
119118
constructor(
120119
msg: string,
121-
err: any,
122-
code?: string,
123-
readonly grpcCode?: number
120+
readonly cause: any,
121+
readonly code?: string
124122
) {
125-
const isErr = err instanceof Error;
126-
super(isErr ? `${msg}: ${err.message}` : msg);
123+
const isErr = cause instanceof Error;
124+
super(isErr ? `${msg}: ${cause.message}` : msg);
127125
if (isErr) {
128-
this.name = err.name;
129-
this.stack = this.stack + '\n\n' + err.stack;
126+
this.name = cause.name;
127+
this.stack = this.stack + '\n\n' + cause.stack;
130128
}
131-
this.code = code ? code : err.code;
129+
this.code ??= cause.code;
132130
}
133131
}
134132

135133
const ProductionUntrustedSegmentKey = 'untrusted-dummy-key';
136-
export const isBuiltFromGHA = process.env.SEGMENT_KEY === ProductionUntrustedSegmentKey;
134+
export const isBuiltFromGHA = process.env.SEGMENT_KEY === ProductionUntrustedSegmentKey;

src/local-ssh/ipc/extensionServiceServer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { ExtensionServiceDefinition, ExtensionServiceImplementation, GetWorkspaceAuthInfoRequest, GetWorkspaceAuthInfoResponse, PingRequest, SendErrorReportRequest, SendLocalSSHUserFlowStatusRequest } from '../../proto/typescript/ipc/v1/ipc';
77
import { Disposable } from '../../common/dispose';
8-
export { ExtensionServiceDefinition } from '../../proto/typescript/ipc/v1/ipc';
98
import { withServerApi } from '../../internalApi';
109
import { Workspace, WorkspaceInstanceStatus_Phase } from '@gitpod/public-api/lib/gitpod/experimental/v1';
1110
import { WorkspaceInfo, WorkspaceInstancePhase } from '@gitpod/gitpod-protocol';
@@ -26,6 +25,7 @@ import * as ssh2 from 'ssh2';
2625
import { ParsedKey } from 'ssh2-streams';
2726
import { isPortUsed } from '../../common/ports';
2827
import { WrapError } from '../../common/utils';
28+
import { ConnectError } from '@bufbuild/connect';
2929

3030
const phaseMap: Record<WorkspaceInstanceStatus_Phase, WorkspaceInstancePhase | undefined> = {
3131
[WorkspaceInstanceStatus_Phase.CREATING]: 'pending',
@@ -124,8 +124,8 @@ class ExtensionServiceImpl implements ExtensionServiceImplementation {
124124
};
125125
} catch (e) {
126126
let code = Status.INTERNAL;
127-
if (e instanceof WrapError && typeof e.grpcCode === 'number') {
128-
code = e.grpcCode;
127+
if (e instanceof WrapError && e.cause instanceof ConnectError) {
128+
code = e.cause.code as unknown as Status;
129129
}
130130
const wrapErr = new WrapError('failed to get workspace auth info', e);
131131
this.logService.error(wrapErr);

src/local-ssh/proxy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { importKey, importKeyBytes } from '@microsoft/dev-tunnels-ssh-keys';
99
import { ExtensionServiceDefinition, GetWorkspaceAuthInfoResponse } from '../proto/typescript/ipc/v1/ipc';
1010
import { Client, ClientError, Status, createChannel, createClient } from 'nice-grpc';
1111
import { retry, timeout } from '../common/async';
12+
import { WrapError } from '../common/utils';
1213
import { WebSocket } from 'ws';
1314
import * as stream from 'stream';
1415
import { ILogService } from '../services/logService';

src/publicApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI {
228228
// https://github.com/gitpod-io/gitpod/blob/d41a38ba83939856e5292e30912f52e749787db1/components/public-api-server/pkg/auth/middleware.go#L73
229229
// https://github.com/gitpod-io/gitpod/blob/d41a38ba83939856e5292e30912f52e749787db1/components/public-api-server/pkg/proxy/errors.go#L30
230230
// NOTE: WrapError will omit error's other properties
231-
throw new WrapError('Failed to call public API', err, 'PublicAPI:' + Code[err.code], err.code);
231+
throw new WrapError('Failed to call public API', err, 'PublicAPI:' + Code[err.code]);
232232
};
233233

234234
return callback().catch(onError);

0 commit comments

Comments
 (0)