Skip to content

Commit 98e308b

Browse files
authored
Merge pull request #5709 from cloudflare/mar/stw-span-without-request
Fix span reporting when actor aborts with pending waitUntil tasks
2 parents 177fb2f + 95435f2 commit 98e308b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/workerd/io/io-context.c++

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ IoContext::IncomingRequest::~IoContext_IncomingRequest() noexcept(false) {
310310
}
311311
}
312312

313-
context->incomingRequests.remove(*this);
314-
315313
KJ_IF_SOME(a, context->actor) {
316314
a.getMetrics().endRequest();
317315
}
@@ -338,6 +336,10 @@ IoContext::IncomingRequest::~IoContext_IncomingRequest() noexcept(false) {
338336
context->waitUntilTasks.clear();
339337
}
340338
}
339+
340+
// Remove incoming request after canceling waitUntil tasks, which may have spans attached that
341+
// require accessing a timer from the active request.
342+
context->incomingRequests.remove(*this);
341343
}
342344

343345
InputGate::Lock IoContext::getInputLock() {

src/workerd/io/tracer.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ void BaseTracer::adjustSpanTime(tracing::CompleteSpan& span) {
411411
KJ_FAIL_ASSERT(
412412
"reported span without current request", span.operationName, hasCompleteTime);
413413
} else {
414-
LOG_NOSENTRY(WARNING, "reported span without current request", span.operationName,
415-
hasCompleteTime);
414+
LOG_WARNING_PERIODICALLY(
415+
"reported span without current request", span.operationName, hasCompleteTime);
416416
}
417417
}
418418
});

0 commit comments

Comments
 (0)