In JSG isolate setup, we only install a logging handler if an inspector is attached or we're running in --verbose mode. This makes jsg::Lock::logWarning() only go to those sinks, and not tail Workers, which differs from IoContext::logWarning()'s behavior.
Relatedly, errors reported via jsg::Lock::reportError() are clearly intended to go to tail workers if they are installed, but we only install an error handler callback when an inspector is attached:
|
if (impl->inspector != kj::none || ::kj::_::Debug::shouldLog(::kj::LogSeverity::INFO)) { |
|
lock->setLoggerCallback([this](jsg::Lock& js, kj::StringPtr message) { |
|
if (impl->inspector != kj::none) { |
|
logMessage(js, static_cast<uint16_t>(cdp::LogType::WARNING), message); |
|
} |
|
KJ_LOG(INFO, "console warning", message); |
|
}); |
|
lock->setErrorReporterCallback([this](jsg::Lock& js, kj::String desc, |
|
const jsg::JsValue& error, const jsg::JsMessage& message) { |
|
// Only add exception to trace when running within an I/O context with a tracer. |
|
KJ_IF_SOME(ioContext, IoContext::tryCurrent()) { |
|
KJ_IF_SOME(tracer, ioContext.getWorkerTracer()) { |
Originally posted by @harrishancock in #6070 (comment)
In JSG isolate setup, we only install a logging handler if an inspector is attached or we're running in
--verbosemode. This makesjsg::Lock::logWarning()only go to those sinks, and not tail Workers, which differs fromIoContext::logWarning()'s behavior.Relatedly, errors reported via
jsg::Lock::reportError()are clearly intended to go to tail workers if they are installed, but we only install an error handler callback when an inspector is attached:workerd/src/workerd/io/worker.c++
Lines 1126 to 1137 in 37dc327
Originally posted by @harrishancock in #6070 (comment)