Skip to content

Commit f5ae093

Browse files
committed
Fix span reporting when actor aborts with pending waitUntil tasks
The span attached to a subrequest is held by the fetch promise, which can be passed to waitUntilTasks. When an actor aborts while another request's waitUntil task is still pending, span reporting can partially fail. Span reporting relies on timing from the current request. If there are reasons not to reorder ~IncomingRequest to cancel pending operations before removing from the list, we can reconsider the assumption that an active request is available during that time.
1 parent 66291c9 commit f5ae093

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ 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,
414+
KJ_LOG(WARNING, "reported span without current request", span.operationName,
415415
hasCompleteTime);
416416
}
417417
}

0 commit comments

Comments
 (0)