diff --git a/src/workerd/io/io-context.c++ b/src/workerd/io/io-context.c++ index 7d4d1c122ed..760e314bc16 100644 --- a/src/workerd/io/io-context.c++ +++ b/src/workerd/io/io-context.c++ @@ -310,8 +310,6 @@ IoContext::IncomingRequest::~IoContext_IncomingRequest() noexcept(false) { } } - context->incomingRequests.remove(*this); - KJ_IF_SOME(a, context->actor) { a.getMetrics().endRequest(); } @@ -338,6 +336,10 @@ IoContext::IncomingRequest::~IoContext_IncomingRequest() noexcept(false) { context->waitUntilTasks.clear(); } } + + // Remove incoming request after canceling waitUntil tasks, which may have spans attached that + // require accessing a timer from the active request. + context->incomingRequests.remove(*this); } InputGate::Lock IoContext::getInputLock() { diff --git a/src/workerd/io/tracer.c++ b/src/workerd/io/tracer.c++ index 31dc07a105e..b11314a23d5 100644 --- a/src/workerd/io/tracer.c++ +++ b/src/workerd/io/tracer.c++ @@ -411,8 +411,8 @@ void BaseTracer::adjustSpanTime(tracing::CompleteSpan& span) { KJ_FAIL_ASSERT( "reported span without current request", span.operationName, hasCompleteTime); } else { - LOG_NOSENTRY(WARNING, "reported span without current request", span.operationName, - hasCompleteTime); + LOG_WARNING_PERIODICALLY( + "reported span without current request", span.operationName, hasCompleteTime); } } });