From 7e6ce286e205916cf606e27afad72df683d880f6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 12 Jan 2018 12:34:25 -0800 Subject: [PATCH 01/25] wip: fix flaky inspector-stop-profile-after-done In test/sequential/test-inspector-stop-profile-after-done.js, if `Profile.start` is received after the debugger is waiting to disconnect, then the process will not terminate. Fixes: https://github.com/nodejs/node/issues/16772 --- test/sequential/sequential.status | 1 - .../test-inspector-stop-profile-after-done.js | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status index 5c0b460154f84f..b95db2a111ea67 100644 --- a/test/sequential/sequential.status +++ b/test/sequential/sequential.status @@ -13,7 +13,6 @@ test-inspector-debug-end : PASS, FLAKY test-inspector-async-hook-setup-at-signal: PASS, FLAKY test-http2-ping-flood : PASS, FLAKY test-http2-settings-flood : PASS, FLAKY -test-inspector-stop-profile-after-done: PASS, FLAKY [$system==linux] diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 7069e490255ce5..ce1495f77e25fe 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -15,13 +15,22 @@ async function runTests() { }, 10);`); const session = await child.connectInspectorSession(); + let stderrString = await child.nextStderrString(); + while (!stderrString.includes('Debugger listening on')) { + stderrString += await child.nextStderrString(); + } + session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' }, - { 'method': 'Profiler.start' }]); - while (await child.nextStderrString() !== - 'Waiting for the debugger to disconnect...'); + { 'method': 'Profiler.start' } + ]); + + while (!stderrString.includes('Waiting for the debugger to disconnect...')) { + stderrString += await child.nextStderrString(); + } + await session.send({ 'method': 'Profiler.stop' }); session.disconnect(); assert.strictEqual(0, (await child.expectShutdown()).exitCode); From 6eb2a64fdb9456636126bd37287154c7eb82e373 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 13 Feb 2018 05:52:21 -0800 Subject: [PATCH 02/25] wip: throw rather than timeout on infinite loop --- .../test-inspector-stop-profile-after-done.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index ce1495f77e25fe..7621ffa5593d08 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -16,9 +16,10 @@ async function runTests() { const session = await child.connectInspectorSession(); let stderrString = await child.nextStderrString(); - while (!stderrString.includes('Debugger listening on')) { - stderrString += await child.nextStderrString(); - } + assert(stderrString.includes('Debugger listening on'), stderrString); + // if (!stderrString.includes('Debugger listening on')) { + // stderrString += await child.nextStderrString(); + // } session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, @@ -27,8 +28,11 @@ async function runTests() { { 'method': 'Profiler.start' } ]); + let limit = 0; while (!stderrString.includes('Waiting for the debugger to disconnect...')) { stderrString += await child.nextStderrString(); + if (limit++ > 10) + throw new Error('no!'); } await session.send({ 'method': 'Profiler.stop' }); From fa0be69cae73ac9d51fe7c36e2acbed327e5c352 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 16 Feb 2018 06:32:23 -0800 Subject: [PATCH 03/25] assert-o-rama --- .../test-inspector-stop-profile-after-done.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 7621ffa5593d08..15f0cfd68e123b 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -17,9 +17,11 @@ async function runTests() { let stderrString = await child.nextStderrString(); assert(stderrString.includes('Debugger listening on'), stderrString); - // if (!stderrString.includes('Debugger listening on')) { - // stderrString += await child.nextStderrString(); - // } + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, + 'For help see https://nodejs.org/en/docs/inspector'); + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, ''); session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, @@ -28,12 +30,12 @@ async function runTests() { { 'method': 'Profiler.start' } ]); - let limit = 0; - while (!stderrString.includes('Waiting for the debugger to disconnect...')) { - stderrString += await child.nextStderrString(); - if (limit++ > 10) - throw new Error('no!'); - } + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, 'Debugger attached.') + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, ''); + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); await session.send({ 'method': 'Profiler.stop' }); session.disconnect(); From 7f6e390321cefa18f97b3248da4cc5015193e280 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 16 Feb 2018 07:09:49 -0800 Subject: [PATCH 04/25] reduce test to basically nothing --- .../test-inspector-stop-profile-after-done.js | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 15f0cfd68e123b..e41f40d2b2a8bb 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -13,33 +13,34 @@ async function runTests() { if (c++ === 10) clearInterval(interval); }, 10);`); - const session = await child.connectInspectorSession(); + // const session = await child.connectInspectorSession(); - let stderrString = await child.nextStderrString(); - assert(stderrString.includes('Debugger listening on'), stderrString); - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, - 'For help see https://nodejs.org/en/docs/inspector'); - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, ''); + // let stderrString = await child.nextStderrString(); + // assert(stderrString.includes('Debugger listening on'), stderrString); + // stderrString = await child.nextStderrString(); + // assert.strictEqual(stderrString, + // 'For help see https://nodejs.org/en/docs/inspector'); + // stderrString = await child.nextStderrString(); + // assert.strictEqual(stderrString, ''); - session.send([ - { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, - { 'method': 'Profiler.enable' }, - { 'method': 'Runtime.runIfWaitingForDebugger' }, - { 'method': 'Profiler.start' } - ]); + // session.send([ + // { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, + // { 'method': 'Profiler.enable' }, + // { 'method': 'Runtime.runIfWaitingForDebugger' }, + // { 'method': 'Profiler.start' } + // ]); - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, 'Debugger attached.') - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, ''); - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); + // stderrString = await child.nextStderrString(); + // assert.strictEqual(stderrString, 'Debugger attached.') + // stderrString = await child.nextStderrString(); + // assert.strictEqual(stderrString, ''); + // stderrString = await child.nextStderrString(); + // assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); - await session.send({ 'method': 'Profiler.stop' }); - session.disconnect(); - assert.strictEqual(0, (await child.expectShutdown()).exitCode); + // await session.send({ 'method': 'Profiler.stop' }); + // session.disconnect(); + // assert.strictEqual(0, (await child.expectShutdown()).exitCode); + child.kill(); } common.crashOnUnhandledRejection(); From 7435ae2625ee672dfaec933eb596000ba6f79897 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 16 Feb 2018 19:12:55 -0800 Subject: [PATCH 05/25] wip: add session --- test/sequential/test-inspector-stop-profile-after-done.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index e41f40d2b2a8bb..f7002ed2e200ec 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -13,7 +13,7 @@ async function runTests() { if (c++ === 10) clearInterval(interval); }, 10);`); - // const session = await child.connectInspectorSession(); + const session = await child.connectInspectorSession(); // let stderrString = await child.nextStderrString(); // assert(stderrString.includes('Debugger listening on'), stderrString); From beb87c3f0006b3b94244570c1f3fa361dad3d516 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 17 Feb 2018 10:11:11 -0800 Subject: [PATCH 06/25] wip: add an await --- test/sequential/test-inspector-stop-profile-after-done.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index f7002ed2e200ec..42c1e0f554299e 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -15,7 +15,7 @@ async function runTests() { }, 10);`); const session = await child.connectInspectorSession(); - // let stderrString = await child.nextStderrString(); + let stderrString = await child.nextStderrString(); // assert(stderrString.includes('Debugger listening on'), stderrString); // stderrString = await child.nextStderrString(); // assert.strictEqual(stderrString, From f934fb171b0ed96d02b96c395316c73212aff536 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 18 Feb 2018 21:33:18 -0800 Subject: [PATCH 07/25] add another await --- test/sequential/test-inspector-stop-profile-after-done.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 42c1e0f554299e..8ec99ec6f759c7 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -16,8 +16,8 @@ async function runTests() { const session = await child.connectInspectorSession(); let stderrString = await child.nextStderrString(); - // assert(stderrString.includes('Debugger listening on'), stderrString); - // stderrString = await child.nextStderrString(); + assert(stderrString.includes('Debugger listening on'), stderrString); + stderrString = await child.nextStderrString(); // assert.strictEqual(stderrString, // 'For help see https://nodejs.org/en/docs/inspector'); // stderrString = await child.nextStderrString(); From b2c0fb2df1d8bc6c1d41edbca13099948d06440d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 18 Feb 2018 21:35:28 -0800 Subject: [PATCH 08/25] a third await --- test/sequential/test-inspector-stop-profile-after-done.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 8ec99ec6f759c7..54eb88489dc43a 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -18,10 +18,10 @@ async function runTests() { let stderrString = await child.nextStderrString(); assert(stderrString.includes('Debugger listening on'), stderrString); stderrString = await child.nextStderrString(); - // assert.strictEqual(stderrString, - // 'For help see https://nodejs.org/en/docs/inspector'); - // stderrString = await child.nextStderrString(); - // assert.strictEqual(stderrString, ''); + assert.strictEqual(stderrString, + 'For help see https://nodejs.org/en/docs/inspector'); + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, ''); // session.send([ // { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, From 9838d7f8a857153e0ae4636872ec7851d81f5599 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 19 Feb 2018 05:58:37 -0800 Subject: [PATCH 09/25] wip: send four command --- .../test-inspector-stop-profile-after-done.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 54eb88489dc43a..18c96504e7797c 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -23,12 +23,12 @@ async function runTests() { stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, ''); - // session.send([ - // { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, - // { 'method': 'Profiler.enable' }, - // { 'method': 'Runtime.runIfWaitingForDebugger' }, - // { 'method': 'Profiler.start' } - // ]); + session.send([ + { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, + { 'method': 'Profiler.enable' }, + { 'method': 'Runtime.runIfWaitingForDebugger' }, + { 'method': 'Profiler.start' } + ]); // stderrString = await child.nextStderrString(); // assert.strictEqual(stderrString, 'Debugger attached.') From 20a565c0a1e20accdbee409cebedefe0323d368d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 19 Feb 2018 18:53:46 -0800 Subject: [PATCH 10/25] wip: reduce messages to 1 --- test/sequential/test-inspector-stop-profile-after-done.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 18c96504e7797c..ed621bfc58cbd9 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -25,9 +25,9 @@ async function runTests() { session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, - { 'method': 'Profiler.enable' }, - { 'method': 'Runtime.runIfWaitingForDebugger' }, - { 'method': 'Profiler.start' } + // { 'method': 'Profiler.enable' }, + // { 'method': 'Runtime.runIfWaitingForDebugger' }, + // { 'method': 'Profiler.start' } ]); // stderrString = await child.nextStderrString(); From 99f7d51335746bcd537264c74771e57dec6a5f12 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 20 Feb 2018 17:32:14 -0800 Subject: [PATCH 11/25] wip: 2 sends --- test/sequential/test-inspector-stop-profile-after-done.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index ed621bfc58cbd9..cca64bc6bc2dfd 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -25,7 +25,7 @@ async function runTests() { session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, - // { 'method': 'Profiler.enable' }, + { 'method': 'Profiler.enable' }, // { 'method': 'Runtime.runIfWaitingForDebugger' }, // { 'method': 'Profiler.start' } ]); From 02fcc817f9295900338dfda1ab9fea220d780d02 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 20 Feb 2018 20:34:43 -0800 Subject: [PATCH 12/25] wip: 3 sends --- test/sequential/test-inspector-stop-profile-after-done.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index cca64bc6bc2dfd..540a4f2fde2f8e 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -26,7 +26,7 @@ async function runTests() { session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, - // { 'method': 'Runtime.runIfWaitingForDebugger' }, + { 'method': 'Runtime.runIfWaitingForDebugger' }, // { 'method': 'Profiler.start' } ]); From 4c6c7886c1db8e59f4d363bff52aecac0133f1d5 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 20 Feb 2018 22:29:05 -0800 Subject: [PATCH 13/25] wip: is it better if we await the whole debugger-attach thing? --- test/sequential/test-inspector-stop-profile-after-done.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 540a4f2fde2f8e..2cb915e4cc912f 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -30,10 +30,10 @@ async function runTests() { // { 'method': 'Profiler.start' } ]); - // stderrString = await child.nextStderrString(); - // assert.strictEqual(stderrString, 'Debugger attached.') - // stderrString = await child.nextStderrString(); - // assert.strictEqual(stderrString, ''); + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, 'Debugger attached.') + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, ''); // stderrString = await child.nextStderrString(); // assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); From 4d3f4c8a7964347d94b0f2dd5442a797ff836894 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 21 Feb 2018 06:50:24 -0800 Subject: [PATCH 14/25] all four sends --- test/sequential/test-inspector-stop-profile-after-done.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 2cb915e4cc912f..7c2d37c33e41af 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -27,15 +27,15 @@ async function runTests() { { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' }, - // { 'method': 'Profiler.start' } + { 'method': 'Profiler.start' } ]); stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Debugger attached.') stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, ''); - // stderrString = await child.nextStderrString(); - // assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); + stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); // await session.send({ 'method': 'Profiler.stop' }); // session.disconnect(); From c57df84eb4e65c6200ab2e632db1b69e675294f7 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 21 Feb 2018 22:09:34 -0800 Subject: [PATCH 15/25] wip: 3 sends but still waiting for debugger disconnect message --- test/sequential/test-inspector-stop-profile-after-done.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 7c2d37c33e41af..ea8b4eb7a0bca9 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -27,7 +27,7 @@ async function runTests() { { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' }, - { 'method': 'Profiler.start' } + // { 'method': 'Profiler.start' } ]); stderrString = await child.nextStderrString(); From be6a7f1f544812eb01f0853fff669da2e705298b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 23 Feb 2018 06:50:37 -0800 Subject: [PATCH 16/25] try moving Profiler.start --- test/sequential/test-inspector-stop-profile-after-done.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index ea8b4eb7a0bca9..87cf4cfe12deb3 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -27,13 +27,15 @@ async function runTests() { { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' }, - // { 'method': 'Profiler.start' } ]); stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Debugger attached.') stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, ''); + + session.send({ 'method': 'Profiler.start' }); + stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); From 053d19e22e4849ab67711dfd3726e4182ed66c94 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 24 Feb 2018 15:37:54 -0800 Subject: [PATCH 17/25] see if moving Profiler.start after program exits still has flaky results or not --- test/sequential/test-inspector-stop-profile-after-done.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 87cf4cfe12deb3..f36ae6d7b136f3 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -33,12 +33,11 @@ async function runTests() { assert.strictEqual(stderrString, 'Debugger attached.') stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, ''); - - session.send({ 'method': 'Profiler.start' }); - stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); + session.send({ 'method': 'Profiler.start' }); + // await session.send({ 'method': 'Profiler.stop' }); // session.disconnect(); // assert.strictEqual(0, (await child.expectShutdown()).exitCode); From 63ad3385e7de3f052a3df239273d204dd57b852e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 25 Feb 2018 12:49:15 -0800 Subject: [PATCH 18/25] add an await --- test/sequential/test-inspector-stop-profile-after-done.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index f36ae6d7b136f3..2f7bdbbb4567c8 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -33,11 +33,12 @@ async function runTests() { assert.strictEqual(stderrString, 'Debugger attached.') stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, ''); + + await session.send({ 'method': 'Profiler.start' }); + stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); - session.send({ 'method': 'Profiler.start' }); - // await session.send({ 'method': 'Profiler.stop' }); // session.disconnect(); // assert.strictEqual(0, (await child.expectShutdown()).exitCode); From aff6d018fd4aca6633fa5503cb50fa6ceb6bdcbb Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 25 Feb 2018 15:53:37 -0800 Subject: [PATCH 19/25] no reason to think this will go any better but why not? --- .../test-inspector-stop-profile-after-done.js | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 2f7bdbbb4567c8..9e582888d5f363 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -5,6 +5,8 @@ common.skipIfInspectorDisabled(); const assert = require('assert'); const { NodeInstance } = require('../common/inspector-helper.js'); +const stderrMessages = []; + async function runTests() { const child = new NodeInstance(['--inspect-brk=0'], `let c = 0; @@ -13,36 +15,24 @@ async function runTests() { if (c++ === 10) clearInterval(interval); }, 10);`); - const session = await child.connectInspectorSession(); - let stderrString = await child.nextStderrString(); - assert(stderrString.includes('Debugger listening on'), stderrString); - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, - 'For help see https://nodejs.org/en/docs/inspector'); - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, ''); + child._process.stderr.on('data', async (data) => { + const message = data.toString(); + stderrMessages.push(message); + if (message.trim() === 'Waiting for the debugger to disconnect...') { + await session.send({ 'method': 'Profiler.stop' }); + session.disconnect(); + assert.strictEqual(0, (await child.expectShutdown()).exitCode); + } + }) + const session = await child.connectInspectorSession(); session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' }, - ]); - - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, 'Debugger attached.') - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, ''); - - await session.send({ 'method': 'Profiler.start' }); - - stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, 'Waiting for the debugger to disconnect...'); - - // await session.send({ 'method': 'Profiler.stop' }); - // session.disconnect(); - // assert.strictEqual(0, (await child.expectShutdown()).exitCode); - child.kill(); + { 'method': 'Profiler.start' } + ]); } common.crashOnUnhandledRejection(); From 37748aa3635529d038e8c74adff08c4fbe78fd09 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 27 Feb 2018 20:54:06 -0800 Subject: [PATCH 20/25] try writing to the process to let it know when to end --- .../test-inspector-stop-profile-after-done.js | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 9e582888d5f363..af96e2ac77a664 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -9,12 +9,15 @@ const stderrMessages = []; async function runTests() { const child = new NodeInstance(['--inspect-brk=0'], - `let c = 0; - const interval = setInterval(() => { - console.log(new Object()); - if (c++ === 10) - clearInterval(interval); - }, 10);`); + `const interval = setInterval(() => { + console.log(new Object()); + }, 10); + process.stdin.on('data', (msg) => { + if (msg.toString() === 'fhqwhgads') { + clearInterval(interval); + process.exit(); + } + });`); child._process.stderr.on('data', async (data) => { const message = data.toString(); @@ -30,9 +33,17 @@ async function runTests() { session.send([ { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, { 'method': 'Profiler.enable' }, - { 'method': 'Runtime.runIfWaitingForDebugger' }, - { 'method': 'Profiler.start' } - ]); + { 'method': 'Runtime.runIfWaitingForDebugger' } + ]); + + await child.nextStderrString(); + await child.nextStderrString(); + await child.nextStderrString(); + const stderrString = await child.nextStderrString(); + assert.strictEqual(stderrString, 'Debugger attached.'); + + session.send({ 'method': 'Profiler.start' }) + setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 200); } common.crashOnUnhandledRejection(); From 9b9abc65b3b6363dc4a0f420d4f6f314057be0f7 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 27 Feb 2018 22:54:19 -0800 Subject: [PATCH 21/25] remove profiler to see if that fixes it --- test/sequential/test-inspector-stop-profile-after-done.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index af96e2ac77a664..bdbc4cfb5368e8 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -23,7 +23,7 @@ async function runTests() { const message = data.toString(); stderrMessages.push(message); if (message.trim() === 'Waiting for the debugger to disconnect...') { - await session.send({ 'method': 'Profiler.stop' }); + // await session.send({ 'method': 'Profiler.stop' }); session.disconnect(); assert.strictEqual(0, (await child.expectShutdown()).exitCode); } @@ -42,7 +42,7 @@ async function runTests() { const stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Debugger attached.'); - session.send({ 'method': 'Profiler.start' }) + // session.send({ 'method': 'Profiler.start' }) setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 200); } From 7143464617ac716199021fa4ccd5d39318ca2656 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Feb 2018 06:41:47 -0800 Subject: [PATCH 22/25] try longer times --- .../test-inspector-stop-profile-after-done.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index bdbc4cfb5368e8..f6549842a63399 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -11,7 +11,7 @@ async function runTests() { const child = new NodeInstance(['--inspect-brk=0'], `const interval = setInterval(() => { console.log(new Object()); - }, 10); + }, 70); process.stdin.on('data', (msg) => { if (msg.toString() === 'fhqwhgads') { clearInterval(interval); @@ -23,7 +23,7 @@ async function runTests() { const message = data.toString(); stderrMessages.push(message); if (message.trim() === 'Waiting for the debugger to disconnect...') { - // await session.send({ 'method': 'Profiler.stop' }); + await session.send({ 'method': 'Profiler.stop' }); session.disconnect(); assert.strictEqual(0, (await child.expectShutdown()).exitCode); } @@ -31,7 +31,7 @@ async function runTests() { const session = await child.connectInspectorSession(); session.send([ - { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 100 } }, + { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 700 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' } ]); @@ -42,8 +42,8 @@ async function runTests() { const stderrString = await child.nextStderrString(); assert.strictEqual(stderrString, 'Debugger attached.'); - // session.send({ 'method': 'Profiler.start' }) - setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 200); + session.send({ 'method': 'Profiler.start' }) + setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 1400); } common.crashOnUnhandledRejection(); From 818e16ff908fecc88812b4cfcea814ebf6fc11d2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Feb 2018 07:43:48 -0800 Subject: [PATCH 23/25] doubling all the times: makes it worse or better or neither? --- test/sequential/test-inspector-stop-profile-after-done.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index f6549842a63399..4252e62f67cad8 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -11,7 +11,7 @@ async function runTests() { const child = new NodeInstance(['--inspect-brk=0'], `const interval = setInterval(() => { console.log(new Object()); - }, 70); + }, 140); process.stdin.on('data', (msg) => { if (msg.toString() === 'fhqwhgads') { clearInterval(interval); @@ -31,7 +31,7 @@ async function runTests() { const session = await child.connectInspectorSession(); session.send([ - { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 700 } }, + { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 1400 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' } ]); @@ -43,7 +43,7 @@ async function runTests() { assert.strictEqual(stderrString, 'Debugger attached.'); session.send({ 'method': 'Profiler.start' }) - setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 1400); + setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 2800); } common.crashOnUnhandledRejection(); From ecd18cff32f84d35a75fe3649e171c895fbe5608 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 28 Feb 2018 22:18:01 -0800 Subject: [PATCH 24/25] increase times some more as it seems to enhance stability --- test/sequential/test-inspector-stop-profile-after-done.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 4252e62f67cad8..104e36b281a17d 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -11,7 +11,7 @@ async function runTests() { const child = new NodeInstance(['--inspect-brk=0'], `const interval = setInterval(() => { console.log(new Object()); - }, 140); + }, 200); process.stdin.on('data', (msg) => { if (msg.toString() === 'fhqwhgads') { clearInterval(interval); @@ -31,7 +31,7 @@ async function runTests() { const session = await child.connectInspectorSession(); session.send([ - { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 1400 } }, + { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 2000 } }, { 'method': 'Profiler.enable' }, { 'method': 'Runtime.runIfWaitingForDebugger' } ]); @@ -43,7 +43,7 @@ async function runTests() { assert.strictEqual(stderrString, 'Debugger attached.'); session.send({ 'method': 'Profiler.start' }) - setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 2800); + setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 4000); } common.crashOnUnhandledRejection(); From e259d26ee5c3ed53a748f8f25b4a8a96a79a4844 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 1 Mar 2018 18:01:21 -0800 Subject: [PATCH 25/25] increase timeouts --- .../test-inspector-stop-profile-after-done.js | 50 ++++++------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js index 104e36b281a17d..15764d84860e8c 100644 --- a/test/sequential/test-inspector-stop-profile-after-done.js +++ b/test/sequential/test-inspector-stop-profile-after-done.js @@ -5,45 +5,27 @@ common.skipIfInspectorDisabled(); const assert = require('assert'); const { NodeInstance } = require('../common/inspector-helper.js'); -const stderrMessages = []; - async function runTests() { const child = new NodeInstance(['--inspect-brk=0'], - `const interval = setInterval(() => { - console.log(new Object()); - }, 200); - process.stdin.on('data', (msg) => { - if (msg.toString() === 'fhqwhgads') { - clearInterval(interval); - process.exit(); - } - });`); - - child._process.stderr.on('data', async (data) => { - const message = data.toString(); - stderrMessages.push(message); - if (message.trim() === 'Waiting for the debugger to disconnect...') { - await session.send({ 'method': 'Profiler.stop' }); - session.disconnect(); - assert.strictEqual(0, (await child.expectShutdown()).exitCode); - } - }) + `let c = 0; + const interval = setInterval(() => { + console.log(new Object()); + if (c++ === 10) + clearInterval(interval); + }, ${common.platformTimeout(30)});`); const session = await child.connectInspectorSession(); session.send([ - { 'method': 'Profiler.setSamplingInterval', 'params': { 'interval': 2000 } }, - { 'method': 'Profiler.enable' }, - { 'method': 'Runtime.runIfWaitingForDebugger' } - ]); - - await child.nextStderrString(); - await child.nextStderrString(); - await child.nextStderrString(); - const stderrString = await child.nextStderrString(); - assert.strictEqual(stderrString, 'Debugger attached.'); - - session.send({ 'method': 'Profiler.start' }) - setTimeout(() => { child._process.stdin.write('fhqwhgads'); }, 4000); + { method: 'Profiler.setSamplingInterval', + params: { interval: common.platformTimeout(300) } }, + { method: 'Profiler.enable' }, + { method: 'Runtime.runIfWaitingForDebugger' }, + { method: 'Profiler.start' }]); + while (await child.nextStderrString() !== + 'Waiting for the debugger to disconnect...'); + await session.send({ method: 'Profiler.stop' }); + session.disconnect(); + assert.strictEqual(0, (await child.expectShutdown()).exitCode); } common.crashOnUnhandledRejection();