File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -729,6 +729,21 @@ kj::Promise<bool> WorkerEntrypoint::test() {
729729 [](IoContext& context, kj::Own<IoContext::IncomingRequest> request) -> kj::Promise<bool > {
730730 TRACE_EVENT (" workerd" , " WorkerEntrypoint::test() waitForFinished()" );
731731 auto result = co_await request->finishScheduled ();
732+
733+ if (result == IoContext_IncomingRequest::FinishScheduledResult::ABORTED) {
734+ // If the test handler throws an exception (without aborting - just a regular exception),
735+ // then `outcome` ends up being EventOutcome::EXCEPTION, which causes us to return false.
736+ // But in that case we are separately relying on the exception being logged as an uncaught
737+ // exception, rather than throwing it.
738+ // This is why we don't rethrow the exception but rather log it as an uncaught exception.
739+ try {
740+ co_await context.onAbort ();
741+ } catch (...) {
742+ auto exception = kj::getCaughtExceptionAsKj ();
743+ KJ_LOG (ERROR, exception);
744+ }
745+ }
746+
732747 bool completed = result == IoContext_IncomingRequest::FinishScheduledResult::COMPLETED;
733748 auto outcome = completed ? context.waitUntilStatus () : EventOutcome::EXCEEDED_CPU;
734749 co_return outcome == EventOutcome::OK;
You can’t perform that action at this time.
0 commit comments