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-
constlists=list._unrefed===true ? unrefedLists : refedLists;
322-
for(varkeyinlists){
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+
constlists=list._unrefed===true ? unrefedLists : refedLists;
321+
for(varkeyinlists){
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+
constdomain=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-
constdomain=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
constwhoamiPath=path.join(process.env.SystemRoot,
515515
'System32','whoami.exe');
516516

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

534526
exports.getCallSite=functiongetCallSite(top){

0 commit comments

Comments
(0)