Fix debug to work when not running under a sandbox

This commit is contained in:
Seth Troisi 2025-06-10 19:47:26 +00:00
parent 9c3f34890f
commit 6f4226fde1
1 changed files with 13 additions and 12 deletions

View File

@ -28,27 +28,28 @@ execSync('node ./scripts/check-build-status.js', {
cwd: root, cwd: root,
}); });
// if debugging is enabled and sandboxing is disabled, use --inspect-brk flag
// note with sandboxing this flag is passed to the binary inside the sandbox
// inside sandbox SANDBOX should be set and sandbox_command.js should fail
const nodeArgs = []; const nodeArgs = [];
let sandboxCommand = undefined;
try { try {
const sandboxCommand = execSync('node scripts/sandbox_command.js', { sandboxCommand = execSync('node scripts/sandbox_command.js', {
cwd: root, cwd: root,
}) })
.toString() .toString()
.trim(); .trim();
if (process.env.DEBUG && !sandboxCommand) {
if (process.env.SANDBOX) {
const port = process.env.DEBUG_PORT || '9229';
nodeArgs.push(`--inspect-brk=0.0.0.0:${port}`);
} else {
nodeArgs.push('--inspect-brk');
}
}
} catch { } catch {
// ignore // ignore
} }
// if debugging is enabled and sandboxing is disabled, use --inspect-brk flag
// note with sandboxing this flag is passed to the binary inside the sandbox
// inside sandbox SANDBOX should be set and sandbox_command.js should fail
if (process.env.DEBUG && !sandboxCommand) {
if (process.env.SANDBOX) {
const port = process.env.DEBUG_PORT || '9229';
nodeArgs.push(`--inspect-brk=0.0.0.0:${port}`);
} else {
nodeArgs.push('--inspect-brk');
}
}
nodeArgs.push('./packages/cli'); nodeArgs.push('./packages/cli');
nodeArgs.push(...process.argv.slice(2)); nodeArgs.push(...process.argv.slice(2));