Skip to content

Commit dfb9902

Browse files
fix(web): fix session dangling after calling run method (#820)
1 parent 0f49ea4 commit dfb9902

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

web-client/iron-remote-desktop/public/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Alexandr Yusuk"
1111
],
1212
"description": "Backend-agnostic Web Component for remote desktop protocols",
13-
"version": "0.5.0",
13+
"version": "0.5.1",
1414
"main": "iron-remote-desktop.js",
1515
"types": "index.d.ts",
1616
"files": [

web-client/iron-remote-desktop/src/services/remote-desktop.service.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@ import { ConfigBuilder } from './ConfigBuilder';
1818
import type { Config } from './Config';
1919
import type { Extension } from '../interfaces/Extension';
2020
import { Observable } from '../lib/Observable';
21+
import type { SessionTerminationInfo } from '../interfaces/SessionTerminationInfo';
2122

2223
type OnRemoteClipboardChanged = (data: ClipboardData) => void;
2324
type OnRemoteReceivedFormatsList = () => void;
2425
type OnForceClipboardUpdate = () => void;
2526

26-
const isIronError = (error: unknown): error is IronError =>
27-
typeof error === 'object' &&
28-
error !== null &&
29-
typeof (error as IronError).backtrace === 'function' &&
30-
typeof (error as IronError).kind === 'function';
31-
3227
export class RemoteDesktopService {
3328
private module: RemoteDesktopModule;
3429
private canvas?: HTMLCanvasElement;
@@ -158,7 +153,7 @@ export class RemoteDesktopService {
158153
throw new Error('could not connect to the session');
159154
});
160155

161-
await this.run(session);
156+
this.run(session);
162157

163158
loggingService.info('Session started.');
164159

@@ -180,19 +175,17 @@ export class RemoteDesktopService {
180175
};
181176
}
182177

183-
async run(session: Session): Promise<Session> {
184-
try {
185-
const termination_info = await session.run();
186-
187-
this.setVisibility(false);
188-
this.raiseSessionEvent({
189-
type: SessionEventType.TERMINATED,
190-
data: 'Session was terminated: ' + termination_info.reason() + '.',
191-
});
192-
193-
return session;
194-
} catch (err) {
195-
if (isIronError(err)) {
178+
run(session: Session) {
179+
session
180+
.run()
181+
.then((terminationInfo: SessionTerminationInfo) => {
182+
this.setVisibility(false);
183+
this.raiseSessionEvent({
184+
type: SessionEventType.TERMINATED,
185+
data: 'Session was terminated: ' + terminationInfo.reason() + '.',
186+
});
187+
})
188+
.catch((err: IronError) => {
196189
this.setVisibility(false);
197190

198191
this.raiseSessionEvent({
@@ -203,10 +196,7 @@ export class RemoteDesktopService {
203196
type: SessionEventType.TERMINATED,
204197
data: 'Session was terminated.',
205198
});
206-
}
207-
208-
throw new Error('could not run the session.');
209-
}
199+
});
210200
}
211201

212202
sendSpecialCombination(specialCombination: SpecialCombination): void {

0 commit comments

Comments
 (0)