Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f872586

Browse filesBrowse files
gurgundayaduh95
authored andcommitted
lib: remove redundant destroyHook checks
PR-URL: #60120 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 2505568 commit f872586
Copy full SHA for f872586

File tree

Expand file treeCollapse file tree

5 files changed

+8
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+8
-19
lines changed
Open diff view settings
Collapse file

‎lib/internal/async_hooks.js‎

Copy file name to clipboardExpand all lines: lib/internal/async_hooks.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ function emitAfterScript(asyncId) {
532532

533533
function emitDestroyScript(asyncId) {
534534
// Return early if there are no destroy callbacks, or invalid asyncId.
535-
if (!hasHooks(kDestroy) || asyncId <= 0)
535+
if (!hasHooks(kDestroy) || !(asyncId > 0))
536536
return;
537537
async_wrap.queueDestroyAsyncId(asyncId);
538538
}
Collapse file

‎lib/internal/process/task_queues.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/task_queues.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const {
2727
getDefaultTriggerAsyncId,
2828
newAsyncId,
2929
initHooksExist,
30-
destroyHooksExist,
3130
emitInit,
3231
emitBefore,
3332
emitAfter,
@@ -94,8 +93,7 @@ function processTicksAndRejections() {
9493
}
9594
}
9695
} finally {
97-
if (destroyHooksExist())
98-
emitDestroy(asyncId);
96+
emitDestroy(asyncId);
9997
}
10098

10199
emitAfter(asyncId);
Collapse file

‎lib/internal/timers.js‎

Copy file name to clipboardExpand all lines: lib/internal/timers.js
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ const {
9292
getDefaultTriggerAsyncId,
9393
newAsyncId,
9494
initHooksExist,
95-
destroyHooksExist,
9695
// The needed emit*() functions.
9796
emitInit,
9897
emitBefore,
@@ -508,8 +507,7 @@ function getTimerCallbacks(runNextTicks) {
508507
} finally {
509508
immediate._onImmediate = null;
510509

511-
if (destroyHooksExist())
512-
emitDestroy(asyncId);
510+
emitDestroy(asyncId);
513511

514512
outstandingQueue.head = immediate = immediate._idleNext;
515513
}
@@ -585,8 +583,7 @@ function getTimerCallbacks(runNextTicks) {
585583
if (timer[kRefed])
586584
timeoutInfo[0]--;
587585

588-
if (destroyHooksExist())
589-
emitDestroy(asyncId);
586+
emitDestroy(asyncId);
590587
}
591588
continue;
592589
}
@@ -621,8 +618,7 @@ function getTimerCallbacks(runNextTicks) {
621618
if (timer[kRefed])
622619
timeoutInfo[0]--;
623620

624-
if (destroyHooksExist())
625-
emitDestroy(asyncId);
621+
emitDestroy(asyncId);
626622
}
627623
}
628624

Collapse file

‎lib/timers.js‎

Copy file name to clipboardExpand all lines: lib/timers.js
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ let timersPromises;
6363
let timers;
6464

6565
const {
66-
destroyHooksExist,
6766
// The needed emit*() functions.
6867
emitDestroy,
6968
} = require('internal/async_hooks');
@@ -78,9 +77,7 @@ function unenroll(item) {
7877
if (item[kHasPrimitive])
7978
delete knownTimersById[item[async_id_symbol]];
8079

81-
// Fewer checks may be possible, but these cover everything.
82-
if (destroyHooksExist() && item[async_id_symbol] !== undefined)
83-
emitDestroy(item[async_id_symbol]);
80+
emitDestroy(item[async_id_symbol]);
8481

8582
L.remove(item);
8683

@@ -239,9 +236,7 @@ function clearImmediate(immediate) {
239236
}
240237
immediate[kRefed] = null;
241238

242-
if (destroyHooksExist() && immediate[async_id_symbol] !== undefined) {
243-
emitDestroy(immediate[async_id_symbol]);
244-
}
239+
emitDestroy(immediate[async_id_symbol]);
245240

246241
immediate._onImmediate = null;
247242

Collapse file
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Error: test
22
at one (*fixtures*async-error.js:4:9)
33
at two (*fixtures*async-error.js:17:9)
4-
at process.processTicksAndRejections (node:internal*process*task_queues:105:5)
4+
at process.processTicksAndRejections (node:internal*process*task_queues:103:5)
55
at async three (*fixtures*async-error.js:20:3)
66
at async four (*fixtures*async-error.js:24:3)
77
at async main (*async_error_nexttick_main.js:7:5)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.