(asyncId, type, triggerAsyncId, resource, isPromiseHook)
| 191 | // from C++ there's no need to perform all the same operations as in |
| 192 | // emitInitScript. |
| 193 | function emitInitNative(asyncId, type, triggerAsyncId, resource, isPromiseHook) { |
| 194 | active_hooks.call_depth += 1; |
| 195 | resource = lookupPublicResource(resource); |
| 196 | // Use a single try/catch for all hooks to avoid setting up one per iteration. |
| 197 | try { |
| 198 | // Using var here instead of let because "for (var ...)" is faster than let. |
| 199 | // Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364 |
| 200 | // eslint-disable-next-line no-var |
| 201 | for (var i = 0; i < active_hooks.array.length; i++) { |
| 202 | if (typeof active_hooks.array[i][init_symbol] === 'function') { |
| 203 | if (isPromiseHook && |
| 204 | active_hooks.array[i][kNoPromiseHook]) { |
| 205 | continue; |
| 206 | } |
| 207 | active_hooks.array[i][init_symbol]( |
| 208 | asyncId, type, triggerAsyncId, |
| 209 | resource, |
| 210 | ); |
| 211 | } |
| 212 | } |
| 213 | } catch (e) { |
| 214 | fatalError(e); |
| 215 | } finally { |
| 216 | active_hooks.call_depth -= 1; |
| 217 | } |
| 218 | |
| 219 | // Hooks can only be restored if there have been no recursive hook calls. |
| 220 | // Also the active hooks do not need to be restored if enable()/disable() |
| 221 | // weren't called during hook execution, in which case active_hooks.tmp_array |
| 222 | // will be null. |
| 223 | if (active_hooks.call_depth === 0 && active_hooks.tmp_array !== null) { |
| 224 | restoreActiveHooks(); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | // Called from native. The asyncId stack handling is taken care of there |
| 229 | // before this is called. |
no test coverage detected
searching dependent graphs…