| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 098cf74 commit 3feaf3d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,8 @@ test-worker-memory: PASS,FLAKY | |||
| 17 | 17 | # https://github.com/nodejs/node/issues/20750 | |
| 18 | 18 | test-http2-client-upload: PASS,FLAKY | |
| 19 | 19 | test-http2-client-upload-reject: PASS,FLAKY | |
| 20 | + # https://github.com/nodejs/node/issues/28106 | ||
| 21 | + test-worker-debug: PASS,FLAKY | ||
| 20 | 22 | ||
| 21 | 23 | [$system==linux] | |
| 22 | 24 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,14 +91,14 @@ class WorkerSession extends EventEmitter { | |||
| 91 | 91 | this.emit(message.method, message); | |
| 92 | 92 | return; | |
| 93 | 93 | } | |
| 94 | - const callback = this._requestCallbacks.get(message.id); | ||
| 95 | - if (callback) { | ||
| 96 | - this._requestCallbacks.delete(message.id); | ||
| 97 | - if (message.error) | ||
| 98 | - callback[1](message.error.message); | ||
| 99 | - else | ||
| 100 | - callback[0](message.result); | ||
| 101 | - } | ||
| 94 | + if (!this._requestCallbacks.has(message.id)) | ||
| 95 | + return; | ||
| 96 | + const [ resolve, reject ] = this._requestCallbacks.get(message.id); | ||
| 97 | + this._requestCallbacks.delete(message.id); | ||
| 98 | + if (message.error) | ||
| 99 | + reject(new Error(message.error.message)); | ||
| 100 | + else | ||
| 101 | + resolve(message.result); | ||
| 102 | 102 | } | |
| 103 | 103 | ||
| 104 | 104 | async waitForBreakAfterCommand(command, script, line) { | |
@@ -144,7 +144,7 @@ async function testBasicWorkerDebug(session, post) { | |||
| 144 | 144 | assert.strictEqual(waitingForDebugger, true); | |
| 145 | 145 | const detached = waitForWorkerDetach(session, sessionId); | |
| 146 | 146 | const workerSession = new WorkerSession(session, sessionId); | |
| 147 | - const contextEvents = Promise.all([ | ||
| 147 | + const contextEventPromises = Promise.all([ | ||
| 148 | 148 | waitForEvent(workerSession, 'Runtime.executionContextCreated'), | |
| 149 | 149 | waitForEvent(workerSession, 'Runtime.executionContextDestroyed') | |
| 150 | 150 | ]); | |
@@ -156,9 +156,10 @@ async function testBasicWorkerDebug(session, post) { | |||
| 156 | 156 | 'Runtime.runIfWaitingForDebugger', __filename, 1); | |
| 157 | 157 | await workerSession.waitForBreakAfterCommand( | |
| 158 | 158 | 'Debugger.resume', __filename, 26); // V8 line number is zero-based | |
| 159 | - assert.strictEqual(await consolePromise, workerMessage); | ||
| 159 | + const msg = await consolePromise; | ||
| 160 | + assert.strictEqual(msg, workerMessage); | ||
| 160 | 161 | workerSession.post('Debugger.resume'); | |
| 161 | - await Promise.all([worker, detached, contextEvents]); | ||
| 162 | + await Promise.all([worker, detached, contextEventPromises]); | ||
| 162 | 163 | } | |
| 163 | 164 | ||
| 164 | 165 | async function testNoWaitOnStart(session, post) { | |
@@ -252,7 +253,7 @@ async function testWaitForDisconnectInWorker(session, post) { | |||
| 252 | 253 | sessionWithoutWaiting.disconnect(); | |
| 253 | 254 | } | |
| 254 | 255 | ||
| 255 | - async function test() { | ||
| 256 | + (async function test() { | ||
| 256 | 257 | const session = new Session(); | |
| 257 | 258 | session.connect(); | |
| 258 | 259 | const post = doPost.bind(null, session); | |
@@ -264,11 +265,14 @@ async function test() { | |||
| 264 | 265 | await runWorker(1); | |
| 265 | 266 | ||
| 266 | 267 | await testNoWaitOnStart(session, post); | |
| 268 | + | ||
| 267 | 269 | await testTwoWorkers(session, post); | |
| 270 | + | ||
| 268 | 271 | await testWaitForDisconnectInWorker(session, post); | |
| 269 | 272 | ||
| 270 | 273 | session.disconnect(); | |
| 271 | 274 | console.log('Test done'); | |
| 272 | - } | ||
| 273 | - | ||
| 274 | - test(); | ||
| 275 | + })().catch((err) => { | ||
| 276 | + console.error(err); | ||
| 277 | + process.abort(); | ||
| 278 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments