MCPcopy Create free account
hub / github.com/ScriptedAlchemy/devtools-debugger-mcp / startDebuggedProcess

Function startDebuggedProcess

tests/node-debug.test.ts:12–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10const debugLog = (...args: unknown[]) => { if (debug) console.log(...args); };
11
12async function startDebuggedProcess(): Promise<{ proc: ChildProcess, port: number }>{
13 const proc = spawn('node', ['--inspect-brk=0', scriptPath], {
14 stdio: ['ignore', 'pipe', 'pipe'],
15 env: { ...process.env, NODE_OPTIONS: '' }
16 });
17
18 const port: number = await new Promise((resolve, reject) => {
19 let resolved = false;
20 proc.stderr?.on('data', (data: Buffer) => {
21 const msg = data.toString();
22 const match = msg.match(/ws:\/\/127\.0\.0\.1:(\d+)/);
23 if (match) {
24 resolved = true;
25 resolve(Number(match[1]));
26 }
27 });
28 proc.on('exit', () => {
29 if (!resolved) reject(new Error('process exited early'));
30 });
31 });
32
33 return { proc, port };
34}
35
36function resolveFrameUrl(frame: any, parsedScripts: any[]): string {
37 const sid = frame && frame.location && frame.location.scriptId;

Callers 1

node-debug.test.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected