diff --git a/v8/src/inspector/v8-console-message.cc b/v8/src/inspector/v8-console-message.cc --- a/v8/src/inspector/v8-console-message.cc +++ b/v8/src/inspector/v8-console-message.cc @@ -1,8 +1,12 @@ } else { for (size_t i = 0; i < m_arguments.size(); ++i) { + v8::Local argValue = m_arguments[i]->Get(isolate); + // Skip eager preview for native Error objects so that the inspector + // does not trigger Error.prepareStackTrace during console logging. + bool shouldPreview = generatePreview && !argValue->IsNativeError(); std::unique_ptr wrapped = - session->wrapObject(context, m_arguments[i]->Get(isolate), "console", - generatePreview); + session->wrapObject(context, argValue, "console", + shouldPreview); inspectedContext = inspector->getContext(contextGroupId, contextId); if (!inspectedContext) return nullptr; if (!wrapped) { diff --git a/v8/src/inspector/value-mirror.cc b/v8/src/inspector/value-mirror.cc --- a/v8/src/inspector/value-mirror.cc +++ b/v8/src/inspector/value-mirror.cc @@ -1,19 +1,8 @@ } - std::optional stack; - { - v8::Local stackValue; - if (getErrorProperty(context, object, toV8String(isolate, "stack")) - .ToLocal(&stackValue) && - stackValue->IsString()) { - String16 stackString = - toProtocolString(isolate, stackValue.As()); - size_t pos = stackString.find("\n at "); - if (pos != String16::kNotFound) { - stack = stackString.substring(pos); - } - } - } + // Avoid touching error.stack while building remote-object descriptions. + // The native stack accessor can invoke Error.prepareStackTrace, which makes + // an attached CDP session observable even for plain console logging. std::optional message; { @@ -30,9 +19,5 @@ if (message.has_value() && message->length() > 0) { description += ": " + *message; } - - if (stack.has_value() && stack->length() > 0) { - description += *stack; - } return description; }