(symbol, asyncId, isPromiseHook)
| 228 | // Called from native. The asyncId stack handling is taken care of there |
| 229 | // before this is called. |
| 230 | function emitHook(symbol, asyncId, isPromiseHook) { |
| 231 | active_hooks.call_depth += 1; |
| 232 | // Use a single try/catch for all hook to avoid setting up one per |
| 233 | // iteration. |
| 234 | try { |
| 235 | // Using var here instead of let because "for (var ...)" is faster than let. |
| 236 | // Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364 |
| 237 | // eslint-disable-next-line no-var |
| 238 | for (var i = 0; i < active_hooks.array.length; i++) { |
| 239 | if (typeof active_hooks.array[i][symbol] === 'function') { |
| 240 | if (isPromiseHook && |
| 241 | active_hooks.array[i][kNoPromiseHook]) { |
| 242 | continue; |
| 243 | } |
| 244 | active_hooks.array[i][symbol](asyncId); |
| 245 | } |
| 246 | } |
| 247 | } catch (e) { |
| 248 | fatalError(e); |
| 249 | } finally { |
| 250 | active_hooks.call_depth -= 1; |
| 251 | } |
| 252 | |
| 253 | // Hooks can only be restored if there have been no recursive hook calls. |
| 254 | // Also the active hooks do not need to be restored if enable()/disable() |
| 255 | // weren't called during hook execution, in which case |
| 256 | // active_hooks.tmp_array will be null. |
| 257 | if (active_hooks.call_depth === 0 && active_hooks.tmp_array !== null) { |
| 258 | restoreActiveHooks(); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | function emitHookFactory(symbol, name) { |
| 263 | const fn = emitHook.bind(undefined, symbol); |
nothing calls this directly
no test coverage detected