Skip to content

Commit

Permalink
Avoid scanning port if cachedEndpoint is still valid
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Jan 16, 2025
1 parent 08b832f commit 3dc3aeb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ async function findWorkingIDEEndpoint(): Promise<string> {
}
}

// 2. Otherwise, scan a range of ports
// 2. Reuse existing endpoint if it's still working
if (cachedEndpoint != null && await testListTools(cachedEndpoint)) {
log('Using cached endpoint, it\'s still working')
return cachedEndpoint
}

// 3. Otherwise, scan a range of ports
for (let port = 63342; port <= 63352; port++) {
const candidateEndpoint = `http://${HOST}:${port}/api`;
log(`Testing port ${port}...`);
Expand Down

0 comments on commit 3dc3aeb

Please sign in to comment.