Skip to content

Commit 61c9cef

Browse files
committed
[protocol] Don't dispose MessageConnection on websocket.close
1 parent 01d1093 commit 61c9cef

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

components/gitpod-protocol/src/messaging/proxy-factory.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
9595
*
9696
* @param target - The object to expose to JSON-RPC methods calls. If this
9797
* is omitted, the proxy won't be able to handle requests, only send them.
98+
* @param propagateConnectionEvents - If true, the MessageConnection open/close are mapped to proxy open/close
9899
*/
99-
constructor(public target?: any) {
100+
constructor(public target?: any, protected propagateConnectionEvents: boolean = false) {
100101
this.waitForConnection();
101102
}
102103

@@ -105,7 +106,9 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
105106
this.connectionPromiseResolve = resolve
106107
);
107108
this.connectionPromise.then(connection => {
108-
connection.onClose(() => this.fireConnectionClosed());
109+
if (this.propagateConnectionEvents) {
110+
connection.onClose(() => this.fireConnectionClosed());
111+
}
109112
this.fireConnectionOpened();
110113
});
111114
}

components/server/src/websocket-connection-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class GitpodJsonRpcProxyFactory<T extends object> extends JsonRpcProxyFactory<T>
169169
protected readonly accessGuard: FunctionAccessGuard,
170170
protected readonly rateLimiter: RateLimiter,
171171
) {
172-
super();
172+
super(undefined, true);
173173
}
174174

175175
protected async onRequest(method: string, ...args: any[]): Promise<any> {

0 commit comments

Comments
 (0)