-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async_hooks: fix nested hooks mutation
In some cases restoreTmpHooks is called too early, this causes active_hooks_array to change during execution of the init hooks. PR-URL: #14143 Ref: #14054 (comment) Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
- Loading branch information
1 parent
3211eff
commit 0c69ec1
Showing
3 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const async_hooks = require('async_hooks'); | ||
const fs = require('fs'); | ||
|
||
let nestedCall = false; | ||
|
||
async_hooks.createHook({ | ||
init: common.mustCall(function(id, type) { | ||
nestedHook.disable(); | ||
if (!nestedCall) { | ||
nestedCall = true; | ||
fs.access(__filename, common.mustCall()); | ||
} | ||
}, 2) | ||
}).enable(); | ||
|
||
const nestedHook = async_hooks.createHook({ | ||
init: common.mustCall(2) | ||
}).enable(); | ||
|
||
fs.access(__filename, common.mustCall()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const async_hooks = require('async_hooks'); | ||
const fs = require('fs'); | ||
|
||
const nestedHook = async_hooks.createHook({ | ||
init: common.mustNotCall() | ||
}); | ||
let nestedCall = false; | ||
|
||
async_hooks.createHook({ | ||
init: common.mustCall(function(id, type) { | ||
nestedHook.enable(); | ||
if (!nestedCall) { | ||
nestedCall = true; | ||
fs.access(__filename, common.mustCall()); | ||
} | ||
}, 2) | ||
}).enable(); | ||
|
||
fs.access(__filename, common.mustCall()); |