diff --git a/lib/internal/util/inspector.js b/lib/internal/util/inspector.js index e237db16a64800..579f93d540faa3 100644 --- a/lib/internal/util/inspector.js +++ b/lib/internal/util/inspector.js @@ -33,7 +33,6 @@ function installConsoleExtensions(commandLineApi) { // Wrap a console implemented by Node.js with features from the VM inspector function wrapConsole(consoleFromNode, consoleFromVM) { - const config = {}; const { consoleCall } = internalBinding('inspector'); for (const key of Object.keys(consoleFromVM)) { // If global console has the same method as inspector console, @@ -42,8 +41,7 @@ function wrapConsole(consoleFromNode, consoleFromVM) { if (consoleFromNode.hasOwnProperty(key)) { consoleFromNode[key] = consoleCall.bind(consoleFromNode, consoleFromVM[key], - consoleFromNode[key], - config); + consoleFromNode[key]); } else { // Add additional console APIs from the inspector consoleFromNode[key] = consoleFromVM[key]; diff --git a/src/env-inl.h b/src/env-inl.h index 47331a61954726..1f66380cf4ca82 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -404,6 +404,16 @@ inline void Environment::TryLoadAddon( } } +#if HAVE_INSPECTOR +inline bool Environment::is_in_inspector_console_call() const { + return is_in_inspector_console_call_; +} + +inline void Environment::set_is_in_inspector_console_call(bool value) { + is_in_inspector_console_call_ = value; +} +#endif + inline Environment::AsyncHooks* Environment::async_hooks() { return &async_hooks_; } diff --git a/src/env.h b/src/env.h index ad2d9fab08299f..c4b3175d6a9ce1 100644 --- a/src/env.h +++ b/src/env.h @@ -874,6 +874,9 @@ class Environment { inline inspector::Agent* inspector_agent() const { return inspector_agent_.get(); } + + inline bool is_in_inspector_console_call() const; + inline void set_is_in_inspector_console_call(bool value); #endif typedef ListHead HandleWrapQueue; @@ -1043,6 +1046,7 @@ class Environment { #if HAVE_INSPECTOR std::unique_ptr inspector_agent_; + bool is_in_inspector_console_call_ = false; #endif // handle_wrap_queue_ and req_wrap_queue_ needs to be at a fixed offset from diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 4a3272e9204995..746cd68ac90c66 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -149,31 +149,22 @@ void InspectorConsoleCall(const FunctionCallbackInfo& info) { Environment* env = Environment::GetCurrent(info); Isolate* isolate = env->isolate(); Local context = isolate->GetCurrentContext(); - CHECK_LT(2, info.Length()); - SlicedArguments call_args(info, /* start */ 3); + CHECK_GE(info.Length(), 2); + SlicedArguments call_args(info, /* start */ 2); if (InspectorEnabled(env)) { Local inspector_method = info[0]; CHECK(inspector_method->IsFunction()); - Local config_value = info[2]; - CHECK(config_value->IsObject()); - Local config_object = config_value.As(); - Local in_call_key = FIXED_ONE_BYTE_STRING(isolate, "in_call"); - bool has_in_call; - if (!config_object->Has(context, in_call_key).To(&has_in_call)) - return; - if (!has_in_call) { - if (config_object->Set(context, - in_call_key, - v8::True(isolate)).IsNothing() || + if (!env->is_in_inspector_console_call()) { + env->set_is_in_inspector_console_call(true); + MaybeLocal ret = inspector_method.As()->Call(context, info.Holder(), call_args.length(), - call_args.out()).IsEmpty()) { + call_args.out()); + env->set_is_in_inspector_console_call(false); + if (ret.IsEmpty()) return; - } } - if (config_object->Delete(context, in_call_key).IsNothing()) - return; } Local node_method = info[1];