diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 4e1e2aa9018b5a..95e90c0b6d6aac 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -343,20 +343,14 @@ } function tryGetCwd(path) { - var threw = true; - var cwd; try { - cwd = process.cwd(); - threw = false; - } finally { - if (threw) { - // getcwd(3) can fail if the current working directory has been deleted. - // Fall back to the directory name of the (absolute) executable path. - // It's not really correct but what are the alternatives? - return path.dirname(process.execPath); - } + return process.cwd(); + } catch (ex) { + // getcwd(3) can fail if the current working directory has been deleted. + // Fall back to the directory name of the (absolute) executable path. + // It's not really correct but what are the alternatives? + return path.dirname(process.execPath); } - return cwd; } function evalScript(name) { diff --git a/lib/timers.js b/lib/timers.js index 6d456da36faf67..1ee254ccde8697 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -232,13 +232,9 @@ function listOnTimeout() { // 4.7) what is in this smaller function. function tryOnTimeout(timer, list) { timer._called = true; - var threw = true; try { ontimeout(timer); - threw = false; - } finally { - if (!threw) return; - + } catch (ex) { // We need to continue processing after domain error handling // is complete, but not by using whatever domain was left over // when the timeout threw its exception. @@ -247,6 +243,7 @@ function tryOnTimeout(timer, list) { // If we threw, we need to process the rest of the list in nextTick. process.nextTick(listOnTimeoutNT, list); process.domain = domain; + throw ex; } } diff --git a/test/message/timeout_throw.out b/test/message/timeout_throw.out index 9ef4f63e3d8b97..0e27247c3802f4 100644 --- a/test/message/timeout_throw.out +++ b/test/message/timeout_throw.out @@ -1,6 +1,6 @@ -*test*message*timeout_throw.js:* - undefined_reference_error_maker; - ^ +timers.js:* + throw ex; + ^ ReferenceError: undefined_reference_error_maker is not defined at Timeout._onTimeout (*test*message*timeout_throw.js:*:*) at ontimeout (timers.js:*:*)