diff --git a/src/workerd/api/queue.c++ b/src/workerd/api/queue.c++ index 5d4d70ef31d7..9c9d8ed8b722 100644 --- a/src/workerd/api/queue.c++ +++ b/src/workerd/api/queue.c++ @@ -525,11 +525,27 @@ kj::Promise QueueCustomEventImpl::run( // reuse the scheduled worker logic and timeout for now. auto completed = co_await incomingRequest->finishScheduled(); - // Log some debug info if the timeout was encountered + // Log some debug info if the request did not complete fully: + // In particular, detect whether or not the users queue() handler function completed + // and include info about other waitUntil tasks that may have caused the request to timeout. if (!completed) { - // TODO(now) log success vs error cases + kj::String statusStr; + KJ_SWITCH_ONEOF(queueEventHolder->event->getCompletionStatus()) { + KJ_CASE_ONEOF(i, QueueEvent::Incomplete) { + statusStr = kj::str("Incomplete"); + break; + } + KJ_CASE_ONEOF(s, QueueEvent::CompletedSuccessfully) { + statusStr = kj::str("Completed Succesfully"); + break; + } + KJ_CASE_ONEOF(e, QueueEvent::CompletedWithError) { + statusStr = kj::str("Completed with error:", e.error); + break; + } + } auto taskTrace = incomingRequest->getContext().getWaitUntilTasks().trace(); - KJ_LOG(WARNING, kj::str("Queue event timed out due to lingering waitUntil tasks:\n", taskTrace)); + KJ_LOG(WARNING, "NOSENTRY queue event timed out. Status: ", statusStr, ". Tasks: ", taskTrace); } co_return WorkerInterface::CustomEvent::Result {