Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion python/jupyterlab_widgets/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function* chain<T>(
}
}

const NO_KERNEL_SESSION_CONTEXT_IDS = new WeakMap<ISessionContext, string>();

/**
* Get the kernel id of current notebook or console panel, this value
* is used as key for `Private.widgetManagerProperty` to store the widget
Expand All @@ -150,7 +152,15 @@ async function getWidgetManagerOwner(
sessionContext: ISessionContext
): Promise<Private.IWidgetManagerOwner> {
await sessionContext.ready;
return sessionContext.session!.kernel!.id;
let id = sessionContext.session?.kernel?.id;
if (id === undefined) {
id = NO_KERNEL_SESSION_CONTEXT_IDS.get(sessionContext);
if (id === undefined) {
id = 'no-kernel-' + base.uuid();
NO_KERNEL_SESSION_CONTEXT_IDS.set(sessionContext, id);
}
}
return id;
}

/**
Expand Down
Loading