Skip to content

Commit

Permalink
fix: use unique ports for modules with DEBUG-INSPECT
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Apr 27, 2023
1 parent 0ca82cf commit 18a70d9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/Instance/Host.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,22 @@ class ModuleHost {
}

// Allow running node with `--inspect`
const inspectFilePath = path.join(moduleInfo.basePath, 'DEBUG-INSPECT')
const inspectExists = !moduleInfo.isPackaged && (await fs.pathExists(inspectFilePath))
let inspectPort = undefined
if (!moduleInfo.isPackaged) {
try {
const inspectFilePath = path.join(moduleInfo.basePath, 'DEBUG-INSPECT')
const inspectFileStr = await fs.readFile(inspectFilePath)
const inspectPortTmp = Number(inspectFileStr.toString().trim())
if (!isNaN(inspectPortTmp)) inspectPort = inspectPortTmp
} catch (e) {
// Ignore
}
}

const cmd = [
// Future: vary depending on module version
// 'node', // For now we can use fork
inspectExists ? '--inspect' : undefined,
inspectPort !== undefined ? `--inspect=${inspectPort}` : undefined,
jsPath,
].filter((v) => !!v)
this.logger.silly(`Connection "${config.label}" command: ${JSON.stringify(cmd)}`)
Expand Down

0 comments on commit 18a70d9

Please sign in to comment.