| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0d79c53 commit ba47632
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,7 @@ const { | |||
| 42 | 42 | ERR_UNHANDLED_ERROR | |
| 43 | 43 | } = require('internal/errors').codes; | |
| 44 | 44 | const { createHook } = require('async_hooks'); | |
| 45 | + const { useDomainTrampoline } = require('internal/async_hooks'); | ||
| 45 | 46 | ||
| 46 | 47 | // TODO(addaleax): Use a non-internal solution for this. | |
| 47 | 48 | const kWeak = Symbol('kWeak'); | |
@@ -145,7 +146,7 @@ function topLevelDomainCallback(cb, ...args) { | |||
| 145 | 146 | // another one. The stack is each entered domain. | |
| 146 | 147 | const stack = []; | |
| 147 | 148 | exports._stack = stack; | |
| 148 | - internalBinding('domain').enable(topLevelDomainCallback); | ||
| 149 | + useDomainTrampoline(topLevelDomainCallback); | ||
| 149 | 150 | ||
| 150 | 151 | function updateExceptionCapture() { | |
| 151 | 152 | if (stack.every((domain) => domain.listenerCount('error') === 0)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,8 +103,13 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative'); | |||
| 103 | 103 | const emitPromiseResolveNative = | |
| 104 | 104 | emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative'); | |
| 105 | 105 | ||
| 106 | - function callbackTrampoline(asyncId, cb, domain_cb, ...args) { | ||
| 107 | - if (hasHooks(kBefore)) | ||
| 106 | + let domain_cb; | ||
| 107 | + function useDomainTrampoline(fn) { | ||
| 108 | + domain_cb = fn; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + function callbackTrampoline(asyncId, cb, ...args) { | ||
| 112 | + if (asyncId && hasHooks(kBefore)) | ||
| 108 | 113 | emitBeforeNative(asyncId); | |
| 109 | 114 | ||
| 110 | 115 | let result; | |
@@ -115,7 +120,7 @@ function callbackTrampoline(asyncId, cb, domain_cb, ...args) { | |||
| 115 | 120 | result = ReflectApply(cb, this, args); | |
| 116 | 121 | } | |
| 117 | 122 | ||
| 118 | - if (hasHooks(kAfter)) | ||
| 123 | + if (asyncId && hasHooks(kAfter)) | ||
| 119 | 124 | emitAfterNative(asyncId); | |
| 120 | 125 | ||
| 121 | 126 | return result; | |
@@ -498,6 +503,7 @@ module.exports = { | |||
| 498 | 503 | emitAfter: emitAfterScript, | |
| 499 | 504 | emitDestroy: emitDestroyScript, | |
| 500 | 505 | registerDestroyHook, | |
| 506 | + useDomainTrampoline, | ||
| 501 | 507 | nativeHooks: { | |
| 502 | 508 | init: emitInitNative, | |
| 503 | 509 | before: emitBeforeNative, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -571,7 +571,6 @@ | |||
| 571 | 571 | 'src/node_contextify.cc', | |
| 572 | 572 | 'src/node_credentials.cc', | |
| 573 | 573 | 'src/node_dir.cc', | |
| 574 | - 'src/node_domain.cc', | ||
| 575 | 574 | 'src/node_env_var.cc', | |
| 576 | 575 | 'src/node_errors.cc', | |
| 577 | 576 | 'src/node_file.cc', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,29 +173,16 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env, | |||
| 173 | 173 | return MaybeLocal<Value>(); | |
| 174 | 174 | } | |
| 175 | 175 | ||
| 176 | - Local<Function> domain_cb = env->domain_callback(); | ||
| 177 | 176 | MaybeLocal<Value> ret; | |
| 178 | 177 | ||
| 179 | - if (asyncContext.async_id != 0 && hook_count != 0) { | ||
| 180 | - MaybeStackBuffer<Local<Value>, 16> args(3 + argc); | ||
| 178 | + if (hook_count != 0) { | ||
| 179 | + MaybeStackBuffer<Local<Value>, 16> args(2 + argc); | ||
| 181 | 180 | args[0] = v8::Number::New(env->isolate(), asyncContext.async_id); | |
| 182 | 181 | args[1] = callback; | |
| 183 | - if (domain_cb.IsEmpty()) { | ||
| 184 | - args[2] = Undefined(env->isolate()); | ||
| 185 | - } else { | ||
| 186 | - args[2] = domain_cb; | ||
| 187 | - } | ||
| 188 | 182 | for (int i = 0; i < argc; i++) { | |
| 189 | - args[i + 3] = argv[i]; | ||
| 183 | + args[i + 2] = argv[i]; | ||
| 190 | 184 | } | |
| 191 | 185 | ret = hook_cb->Call(env->context(), recv, args.length(), &args[0]); | |
| 192 | - } else if (asyncContext.async_id == 0 && !domain_cb.IsEmpty()) { | ||
| 193 | - MaybeStackBuffer<Local<Value>, 16> args(1 + argc); | ||
| 194 | - args[0] = callback; | ||
| 195 | - for (int i = 0; i < argc; i++) { | ||
| 196 | - args[i + 1] = argv[i]; | ||
| 197 | - } | ||
| 198 | - ret = domain_cb->Call(env->context(), recv, args.length(), &args[0]); | ||
| 199 | 186 | } else { | |
| 200 | 187 | ret = callback->Call(env->context(), recv, argc, argv); | |
| 201 | 188 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -441,7 +441,6 @@ constexpr size_t kFsStatsBufferLength = | |||
| 441 | 441 | V(async_hooks_promise_resolve_function, v8::Function) \ | |
| 442 | 442 | V(buffer_prototype_object, v8::Object) \ | |
| 443 | 443 | V(crypto_key_object_constructor, v8::Function) \ | |
| 444 | - V(domain_callback, v8::Function) \ | ||
| 445 | 444 | V(domexception_function, v8::Function) \ | |
| 446 | 445 | V(enhance_fatal_stack_after_inspector, v8::Function) \ | |
| 447 | 446 | V(enhance_fatal_stack_before_inspector, v8::Function) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,6 @@ | |||
| 42 | 42 | V(config) \ | |
| 43 | 43 | V(contextify) \ | |
| 44 | 44 | V(credentials) \ | |
| 45 | - V(domain) \ | ||
| 46 | 45 | V(errors) \ | |
| 47 | 46 | V(fs) \ | |
| 48 | 47 | V(fs_dir) \ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments