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

Function main

test/parallel/test-inspector-connect-main-thread.js:102–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100}
101
102async function main() {
103 assert.throws(
104 () => {
105 const session = new Session();
106 session.connectToMainThread();
107 },
108 {
109 code: 'ERR_INSPECTOR_NOT_WORKER',
110 name: 'Error',
111 message: 'Current thread is not a worker'
112 }
113 );
114 const sharedBuffer = new SharedArrayBuffer(1);
115 const arrayBuffer = new Uint8Array(sharedBuffer);
116 arrayBuffer[0] = 1;
117 const worker = await startWorker(false, sharedBuffer);
118 worker.onConsoleRequest.then(doConsoleLog.bind(null, arrayBuffer)).then(common.mustCall());
119 assert.strictEqual(toDebug(), 400);
120 assert.deepStrictEqual(await worker.onMessagesSent, [
121 'Debugger.enable',
122 'Runtime.enable',
123 'Debugger.setBreakpointByUrl',
124 'Debugger.evaluateOnCallFrame',
125 'Debugger.resume',
126 ]);
127}
128
129async function childMain() {
130 // Ensures the worker does not terminate too soon

Calls 5

connectToMainThreadMethod · 0.95
toDebugFunction · 0.85
startWorkerFunction · 0.70
thenMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…