-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Correctly dispose TerminalManager even if terminals are not available
#17876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for making a pull request to jupyterlab! |
|
|
||
| // Start polling with exponential backoff. | ||
| this._pollModels = new Poll({ | ||
| const pollModels = (this._pollModels = new Poll({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an alternative to avoid changing the types could be to move the block that checks this.isAvailable() a bit below, before setting the this._ready promise which then starts the polls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we could do that but it feels like updating the types is fine:
- it is a private variable
- if a user/extension called
refreshRunning()with poll initialized it could have unexpected effects; with this PR as is it would just do nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtpio is changing the types a big concern? If so I can rework this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's likely fine.
Probably we could also consider instantiating a NoopManager at the plugin level when the terminals are not available?
Something like the following in:
jupyterlab/packages/services-extension/src/index.ts
Lines 257 to 278 in 4cdd285
| /** | |
| * The terminal manager plugin. | |
| */ | |
| const terminalManagerPlugin: ServiceManagerPlugin<Terminal.IManager> = { | |
| id: '@jupyterlab/services-extension:terminal-manager', | |
| description: 'The terminal manager plugin.', | |
| autoStart: true, | |
| provides: ITerminalManager, | |
| optional: [IServerSettings, IConnectionStatus], | |
| activate: ( | |
| _: null, | |
| serverSettings: ServerConnection.ISettings | undefined, | |
| connectionStatus: IConnectionStatus | undefined | |
| ): Terminal.IManager => { | |
| return new TerminalManager({ | |
| serverSettings, | |
| standby: () => { | |
| return !connectionStatus?.isConnected || 'when-hidden'; | |
| } | |
| }); | |
| } | |
| }; |
if (!Terminal.isAvailable()) {
return new TerminalManager.NoopManager();
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense, but this might be a potentially breaking change - see my comment in #17930 which I opened to explore this as a follow-up (since I would like to backport this PR to 4.4.x).
jtpio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…n if terminals are not available
…nals are not available (#17934) Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
References
Fixes #17875
Code changes
User-facing changes
None
Backwards-incompatible changes
None