diff --git a/packages/myst-cli/src/build/build.ts b/packages/myst-cli/src/build/build.ts index 73eb39d80..ae6f15dd6 100644 --- a/packages/myst-cli/src/build/build.ts +++ b/packages/myst-cli/src/build/build.ts @@ -186,4 +186,6 @@ export async function build(session: ISession, files: string[], opts: BuildOpts) await buildSite(session, opts); } } + + session.maybeDisposeJupyterSessionManager(); } diff --git a/packages/myst-cli/src/session/session.ts b/packages/myst-cli/src/session/session.ts index 20ba21b33..6e823c0d9 100644 --- a/packages/myst-cli/src/session/session.ts +++ b/packages/myst-cli/src/session/session.ts @@ -75,6 +75,7 @@ export class Session implements ISession { _shownUpgrade = false; _latestVersion?: string; _jupyterSessionManager: SessionManager | undefined | null = null; + _disposeJupyterSessionManager?: () => void; get log(): Logger { return this.$logger; @@ -207,4 +208,12 @@ export class Session implements ISession { return undefined; } } + + maybeDisposeJupyterSessionManager() { + if (this._disposeJupyterSessionManager === undefined) { + return; + }; + this._disposeJupyterSessionManager(); + this._disposeJupyterSessionManager = undefined; + } } diff --git a/packages/myst-cli/src/session/types.ts b/packages/myst-cli/src/session/types.ts index 3dc22d3a2..b82db1a4a 100644 --- a/packages/myst-cli/src/session/types.ts +++ b/packages/myst-cli/src/session/types.ts @@ -26,6 +26,7 @@ export type ISession = { loadPlugins(): Promise; getAllWarnings(ruleId: RuleId): (BuildWarning & { file: string })[]; jupyterSessionManager(): Promise; + maybeDisposeJupyterSessionManager(): void; }; export type ISessionWithCache = ISession & {