test: mark test-worker-debug as flaky

Also try to make more traceable.

PR-URL: https://github.com/nodejs/node/pull/28035
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit is contained in:
Refael Ackermann 2019-06-05 18:03:08 -04:00
parent 2f8cf5e5b5
commit 65a5f7b65f
2 changed files with 21 additions and 15 deletions

View File

@ -17,6 +17,8 @@ test-worker-memory: PASS,FLAKY
# https://github.com/nodejs/node/issues/20750 # https://github.com/nodejs/node/issues/20750
test-http2-client-upload: PASS,FLAKY test-http2-client-upload: PASS,FLAKY
test-http2-client-upload-reject: PASS,FLAKY test-http2-client-upload-reject: PASS,FLAKY
# https://github.com/nodejs/node/issues/28106
test-worker-debug: PASS,FLAKY
[$system==linux] [$system==linux]

View File

@ -91,14 +91,14 @@ class WorkerSession extends EventEmitter {
this.emit(message.method, message); this.emit(message.method, message);
return; return;
} }
const callback = this._requestCallbacks.get(message.id); if (!this._requestCallbacks.has(message.id))
if (callback) { return;
const [ resolve, reject ] = this._requestCallbacks.get(message.id);
this._requestCallbacks.delete(message.id); this._requestCallbacks.delete(message.id);
if (message.error) if (message.error)
callback[1](message.error.message); reject(new Error(message.error.message));
else else
callback[0](message.result); resolve(message.result);
}
} }
async waitForBreakAfterCommand(command, script, line) { async waitForBreakAfterCommand(command, script, line) {
@ -144,7 +144,7 @@ async function testBasicWorkerDebug(session, post) {
assert.strictEqual(waitingForDebugger, true); assert.strictEqual(waitingForDebugger, true);
const detached = waitForWorkerDetach(session, sessionId); const detached = waitForWorkerDetach(session, sessionId);
const workerSession = new WorkerSession(session, sessionId); const workerSession = new WorkerSession(session, sessionId);
const contextEvents = Promise.all([ const contextEventPromises = Promise.all([
waitForEvent(workerSession, 'Runtime.executionContextCreated'), waitForEvent(workerSession, 'Runtime.executionContextCreated'),
waitForEvent(workerSession, 'Runtime.executionContextDestroyed') waitForEvent(workerSession, 'Runtime.executionContextDestroyed')
]); ]);
@ -156,9 +156,10 @@ async function testBasicWorkerDebug(session, post) {
'Runtime.runIfWaitingForDebugger', __filename, 1); 'Runtime.runIfWaitingForDebugger', __filename, 1);
await workerSession.waitForBreakAfterCommand( await workerSession.waitForBreakAfterCommand(
'Debugger.resume', __filename, 26); // V8 line number is zero-based 'Debugger.resume', __filename, 26); // V8 line number is zero-based
assert.strictEqual(await consolePromise, workerMessage); const msg = await consolePromise;
assert.strictEqual(msg, workerMessage);
workerSession.post('Debugger.resume'); workerSession.post('Debugger.resume');
await Promise.all([worker, detached, contextEvents]); await Promise.all([worker, detached, contextEventPromises]);
} }
async function testNoWaitOnStart(session, post) { async function testNoWaitOnStart(session, post) {
@ -252,7 +253,7 @@ async function testWaitForDisconnectInWorker(session, post) {
sessionWithoutWaiting.disconnect(); sessionWithoutWaiting.disconnect();
} }
async function test() { (async function test() {
const session = new Session(); const session = new Session();
session.connect(); session.connect();
const post = doPost.bind(null, session); const post = doPost.bind(null, session);
@ -264,11 +265,14 @@ async function test() {
await runWorker(1); await runWorker(1);
await testNoWaitOnStart(session, post); await testNoWaitOnStart(session, post);
await testTwoWorkers(session, post); await testTwoWorkers(session, post);
await testWaitForDisconnectInWorker(session, post); await testWaitForDisconnectInWorker(session, post);
session.disconnect(); session.disconnect();
console.log('Test done'); console.log('Test done');
} })().catch((err) => {
console.error(err);
test(); process.abort();
});