MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / checkIdeConnection

Function checkIdeConnection

source code/utils/ide.ts:404–435  ·  view source on GitHub ↗

* Checks if the IDE connection is responding by testing if the port is open * @param host Host to connect to * @param port Port to connect to * @param timeout Optional timeout in milliseconds (defaults to 500ms) * @returns true if the port is open, false otherwise

(
  host: string,
  port: number,
  timeout = 500,
)

Source from the content-addressed store, hash-verified

402 * @returns true if the port is open, false otherwise
403 */
404async function checkIdeConnection(
405 host: string,
406 port: number,
407 timeout = 500,
408): Promise<boolean> {
409 try {
410 return new Promise(resolve => {
411 const socket = createConnection({
412 host: host,
413 port: port,
414 timeout: timeout,
415 })
416
417 socket.on('connect', () => {
418 socket.destroy()
419 void resolve(true)
420 })
421
422 socket.on('error', () => {
423 void resolve(false)
424 })
425
426 socket.on('timeout', () => {
427 socket.destroy()
428 void resolve(false)
429 })
430 })
431 } catch (_) {
432 // Invalid URL or other errors
433 return false
434 }
435}
436
437/**
438 * Resolve the Windows USERPROFILE path. WSL often doesn't pass USERPROFILE

Callers 2

cleanupStaleIdeLockfilesFunction · 0.85
ide.tsFile · 0.85

Calls 1

resolveFunction · 0.70

Tested by

no test coverage detected