Skip to content

Commit

Permalink
add onDidEndSession disposable to the session's disposables
Browse files Browse the repository at this point in the history
  • Loading branch information
seeM committed Nov 28, 2024
1 parent 0e3cf4f commit 065e6e7
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,20 @@ export class RuntimeSessionService extends Disposable implements IRuntimeSession

private async doShutdownRuntimeSession(
session: ILanguageRuntimeSession, exitReason: RuntimeExitReason): Promise<void> {

const sessionDisposables = this._sessionDisposables.get(session.sessionId);
if (!sessionDisposables) {
throw new Error(`No disposables found for session ${session.sessionId}`);
}

// We wait for `onDidEndSession()` rather than `RuntimeState.Exited`, because the former
// generates some Console output that must finish before starting up a new runtime:
let disposable: IDisposable | undefined;
const promise = new Promise<void>(resolve => {
disposable = session.onDidEndSession((exit) => {
disposable = sessionDisposables.add(session.onDidEndSession((exit) => {
resolve();
disposable?.dispose();
});
}));
});

const timeout = new Promise<void>((_, reject) => {
Expand Down

0 comments on commit 065e6e7

Please sign in to comment.