Skip to content

Commit 9d1e409

Browse files
BridgeARMylesBorins
authored andcommitted
tools: enable no-unsafe-finally
This enables the `no-unsafe-finally` eslint rule to make sure we have a proper control flow in try / catch. Backport-PR-URL: #19244 PR-URL: #18745 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d795865 commit 9d1e409

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ rules:
157157
}]
158158
no-tabs: error
159159
no-trailing-spaces: error
160+
no-unsafe-finally: error
160161
object-curly-spacing: [error, always]
161162
one-var-declaration-per-line: error
162163
operator-linebreak: [error, after]

lib/timers.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,24 @@ function tryOnTimeout(timer, list) {
314314
}
315315
}
316316

317-
if (!threw) return;
318-
319-
// Postpone all later list events to next tick. We need to do this
320-
// so that the events are called in the order they were created.
321-
const lists = list._unrefed === true ? unrefedLists : refedLists;
322-
for (var key in lists) {
323-
if (key > list.msecs) {
324-
lists[key].nextTick = true;
317+
if (threw) {
318+
// Postpone all later list events to next tick. We need to do this
319+
// so that the events are called in the order they were created.
320+
const lists = list._unrefed === true ? unrefedLists : refedLists;
321+
for (var key in lists) {
322+
if (key > list.msecs) {
323+
lists[key].nextTick = true;
324+
}
325325
}
326+
// We need to continue processing after domain error handling
327+
// is complete, but not by using whatever domain was left over
328+
// when the timeout threw its exception.
329+
const domain = process.domain;
330+
process.domain = null;
331+
// If we threw, we need to process the rest of the list in nextTick.
332+
process.nextTick(listOnTimeoutNT, list);
333+
process.domain = domain;
326334
}
327-
// We need to continue processing after domain error handling
328-
// is complete, but not by using whatever domain was left over
329-
// when the timeout threw its exception.
330-
const domain = process.domain;
331-
process.domain = null;
332-
// If we threw, we need to process the rest of the list in nextTick.
333-
process.nextTick(listOnTimeoutNT, list);
334-
process.domain = domain;
335335
}
336336
}
337337

test/common/index.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -514,21 +514,13 @@ exports.canCreateSymLink = function() {
514514
const whoamiPath = path.join(process.env.SystemRoot,
515515
'System32', 'whoami.exe');
516516

517-
let err = false;
518-
let output = '';
519-
520517
try {
521-
output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
518+
const output = execSync(`${whoamiPath} /priv`, { timout: 1000 });
519+
return output.includes('SeCreateSymbolicLinkPrivilege');
522520
} catch (e) {
523-
err = true;
524-
} finally {
525-
if (err || !output.includes('SeCreateSymbolicLinkPrivilege')) {
526-
return false;
527-
}
521+
return false;
528522
}
529523
}
530-
531-
return true;
532524
};
533525

534526
exports.getCallSite = function getCallSite(top) {

0 commit comments

Comments
 (0)