Skip to content

Commit dc6f4cc

Browse files
authored
data explorer: fix disposable leak for duckdb instances (#9656)
fyi that Claude helped out on this PR! ### Release Notes #### New Features - N/A #### Bug Fixes - #9644 Fixes disposable leak on reopen of DuckDB files. ### QA Notes - open and close a duckdb data explorer a few times - should not see any disposable leak in the developer tools
1 parent 4f32620 commit dc6f4cc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/vs/workbench/services/positronDataExplorer/browser/positronDataExplorerService.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,15 @@ class PositronDataExplorerService extends Disposable implements IPositronDataExp
394394
* PositronDataExplorerEditor is instantiated.
395395
*/
396396
private registerDataExplorerClient(languageName: string, client: DataExplorerClientInstance) {
397+
const instance = this._register(new PositronDataExplorerInstance(
398+
languageName,
399+
client
400+
));
401+
397402
// Set the Positron data explorer client instance.
398403
this._positronDataExplorerInstances.set(
399404
client.identifier,
400-
new PositronDataExplorerInstance(
401-
languageName,
402-
client
403-
)
405+
instance
404406
);
405407

406408
this._register(client.onDidClose(() => {
@@ -421,13 +423,14 @@ class PositronDataExplorerService extends Disposable implements IPositronDataExp
421423
* @param dataExplorerClientInstance The DataExplorerClientInstance for the editor.
422424
*/
423425
private closeEditor(dataExplorerClientInstance: DataExplorerClientInstance) {
424-
// Get the data explorer client instance. If it was found, delete it and dispose it.
426+
// Get the data explorer client instance. If it was found, delete it from the map.
427+
// We don't need to dispose it explicitly here as it's already registered with the parent
428+
// disposable store and will be disposed when the service is disposed.
425429
const positronDataExplorerInstance = this._positronDataExplorerInstances.get(
426430
dataExplorerClientInstance.identifier
427431
);
428432
if (positronDataExplorerInstance) {
429433
this._positronDataExplorerInstances.delete(dataExplorerClientInstance.identifier);
430-
positronDataExplorerInstance.dispose();
431434
}
432435
}
433436

0 commit comments

Comments
 (0)