-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Summary
The NativePythonFinderImpl class has resource management issues that can lead to memory leaks and orphaned processes.
Issues Identified
1. Worker Pool Not Disposed
In nativePythonFinder.ts, the dispose() method only disposes the connection but not the worker pool:
public dispose() {
this.connection.dispose();
// BUG: this.pool is never stopped/disposed!
}The worker pool created at construction (line ~112) runs indefinitely with workers waiting for queue items. When the finder is disposed, these workers remain active, blocked on promises that will never resolve.
Fix:
public dispose() {
this.pool.stop(); // Stop worker pool first
this.connection.dispose();
}2. Disposables in start() Not Tracked
In the start() method (lines 206-275), disposables are created and pushed to a local array:
const disposables: Disposable[] = [];
// ... disposables.push(...)
disposables.push(
connection,
connection.onError(...),
connection.onNotification('log', ...),
// etc.
);These disposables are only disposed when connection.onClose() fires. If the connection is disposed directly (or never properly established), these subscriptions leak.
Impact: Event handlers for log, telemetry, etc. may remain registered even after the finder is disposed.
Fix: Track disposables at class level and dispose them in dispose():
private readonly disposables: Disposable[] = [];
public dispose() {
this.pool.stop();
this.disposables.forEach(d => d.dispose());
this.connection.dispose();
}Files to Modify
src/managers/common/nativePythonFinder.ts
Related
- Complements Root Cause Analysis: Discovery stuck indefinitely (#1081, #956) #1140 which addresses timeout and error handling issues