Skip to content

Commit 0b22d4d

Browse files
committed
refactor: scan Jupyter port range (8888-8895) during cleanup
- Change from single port 8888 to range 8888-8895 - Jupyter increments port when 8888 is busy, so we need to check multiple ports - Add timing measurement for port-based cleanup phase - Log cleanup duration for performance monitoring The loop adds minimal overhead as each port check is fast when no process is listening. Timing is logged at debug level for monitoring.
1 parent a977208 commit 0b22d4d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/kernels/deepnote/deepnoteServerStarter.node.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,12 +839,21 @@ export class DeepnoteServerStarter implements IDeepnoteServerStarter, IExtension
839839
*/
840840
private async cleanupOrphanedProcesses(): Promise<void> {
841841
try {
842+
const startTime = Date.now();
842843
logger.info('Checking for orphaned deepnote-toolkit processes...');
843844

844845
// First, clean up any orphaned processes using known ports
845-
// This catches LSP servers (2087) and Jupyter servers (8888+) that may be stuck
846+
// This catches LSP servers (2087) and Jupyter servers (8888-8895) that may be stuck
846847
await this.cleanupProcessesByPort(2087); // Python LSP server
847-
await this.cleanupProcessesByPort(8888); // Default Jupyter port
848+
849+
// Scan common Jupyter port range (8888-8895)
850+
// Jupyter typically uses 8888 but will increment if that port is busy
851+
for (let port = 8888; port <= 8895; port++) {
852+
await this.cleanupProcessesByPort(port);
853+
}
854+
855+
const portCleanupTime = Date.now() - startTime;
856+
logger.debug(`Port-based cleanup completed in ${portCleanupTime}ms`);
848857

849858
const processService = await this.processServiceFactory.create(undefined);
850859

0 commit comments

Comments
 (0)