MCPcopy Index your code
hub / github.com/nodejs/node / testBasicWorkerDebug

Function testBasicWorkerDebug

test/parallel/test-worker-debug.js:129–160  ·  view source on GitHub ↗
(session, post)

Source from the content-addressed store, hash-verified

127}
128
129async function testBasicWorkerDebug(session, post) {
130 // 1. Do 'enable' with waitForDebuggerOnStart = true
131 // 2. Run worker. It should break on start.
132 // 3. Enable Runtime (to get console message) and Debugger. Resume.
133 // 4. Breaks on the 'debugger' statement. Resume.
134 // 5. Console message received, worker runs to a completion.
135 // 6. contextCreated/contextDestroyed had been properly dispatched
136 console.log('Test basic debug scenario');
137 await post('NodeWorker.enable', { waitForDebuggerOnStart: true });
138 const attached = waitForWorkerAttach(session);
139 const worker = runWorker(1);
140 const { sessionId, waitingForDebugger } = await attached;
141 assert.strictEqual(waitingForDebugger, true);
142 const detached = waitForWorkerDetach(session, sessionId);
143 const workerSession = new WorkerSession(session, sessionId);
144 const contextEventPromises = Promise.all([
145 waitForEvent(workerSession, 'Runtime.executionContextCreated'),
146 waitForEvent(workerSession, 'Runtime.executionContextDestroyed'),
147 ]);
148 const consolePromise = waitForEvent(workerSession, 'Runtime.consoleAPICalled')
149 .then((notification) => notification.params.args[0].value);
150 await workerSession.post('Debugger.enable');
151 await workerSession.post('Runtime.enable');
152 await workerSession.waitForBreakAfterCommand(
153 'Runtime.runIfWaitingForDebugger', __filename, 1);
154 await workerSession.waitForBreakAfterCommand(
155 'Debugger.resume', __filename, 25); // V8 line number is zero-based
156 const msg = await consolePromise;
157 assert.strictEqual(msg, workerMessage);
158 workerSession.post('Debugger.resume');
159 await Promise.all([worker, detached, contextEventPromises]);
160}
161
162async function testNoWaitOnStart(session, post) {
163 console.log('Test disabled waitForDebuggerOnStart');

Callers 1

Calls 10

postMethod · 0.95
waitForWorkerAttachFunction · 0.85
waitForWorkerDetachFunction · 0.85
allMethod · 0.80
postFunction · 0.70
runWorkerFunction · 0.70
waitForEventFunction · 0.70
logMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…