From 0753bc17b61ae34e2e99c2726274478a04da6fbd Mon Sep 17 00:00:00 2001 From: "Sakthipriyan Vairamani (thefourtheye)" Date: Mon, 16 Jan 2017 00:32:32 +0530 Subject: [PATCH] test: increase timeout in break-on-uncaught As the failures suggest, this test expects the uncaught exception to be thrown within 100 milliseconds, but on some of the test machines it takes longer than that limit to notify the exception. Thats why the test was failing. This patch polls every 10 ms to see if the exception is received. PR-URL: https://github.com/nodejs/node/pull/10822 Reviewed-By: Rich Trott Reviewed-By: Santiago Gimeno --- test/debugger/test-debug-break-on-uncaught.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/debugger/test-debug-break-on-uncaught.js b/test/debugger/test-debug-break-on-uncaught.js index 2d1deb20bccac8..cfe72bb67b4f02 100644 --- a/test/debugger/test-debug-break-on-uncaught.js +++ b/test/debugger/test-debug-break-on-uncaught.js @@ -73,6 +73,7 @@ function runScenario(scriptName, throwsOnLine, next) { client.connect(port); } + let interval; function runTest(client) { client.req( { @@ -91,14 +92,15 @@ function runScenario(scriptName, throwsOnLine, next) { client.reqContinue(function(error) { assert.ifError(error); - setTimeout(assertHasPaused.bind(null, client), 100); + interval = setInterval(assertHasPaused.bind(null, client), 10); }); } ); } function assertHasPaused(client) { - assert(exceptions.length, 'no exceptions thrown, race condition in test?'); + if (!exceptions.length) return; + assert.strictEqual(exceptions.length, 1, 'debugger did not pause on exception'); assert.strictEqual(exceptions[0].uncaught, true); @@ -106,5 +108,6 @@ function runScenario(scriptName, throwsOnLine, next) { assert.strictEqual(exceptions[0].sourceLine + 1, throwsOnLine); asserted = true; client.reqContinue(assert.ifError); + clearInterval(interval); } }