Skip to content

Commit

Permalink
Update event loop stall handling (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Aug 30, 2024
1 parent d29fdb0 commit bed7e1a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion builtins/web/fetch/fetch_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ bool handle_incoming_request(host_api::HttpIncomingRequest *request) {
}

if (!success) {
fprintf(stderr, "Internal error.");
fprintf(stderr, "Warning: JS event loop terminated without completing the request.\n");
}

if (ENGINE->debug_logging_enabled() && ENGINE->has_pending_async_tasks()) {
Expand Down
2 changes: 0 additions & 2 deletions runtime/event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ bool EventLoop::run_event_loop(api::Engine *engine, double total_compute) {
if (tasks_size == 0) {
exit_event_loop();
MOZ_ASSERT(!interest_complete());
fprintf(stderr, "event loop error - both task and job queues are empty, but expected "
"operations did not resolve");
return false;
}

Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/eventloop-stall/eventloop-stall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { strictEqual, deepStrictEqual, throws } from "../../assert.js";

addEventListener("fetch", (evt) =>
evt.respondWith(
(async () => {
return new Response(new ReadableStream({
start(_controller) {
// stall
},
}));
})()
)
);
1 change: 1 addition & 0 deletions tests/e2e/eventloop-stall/expect_serve_stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stderr [0] :: Warning: JS event loop terminated without completing the request.
1 change: 1 addition & 0 deletions tests/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function(test_integration TEST_NAME)
set_tests_properties(integration-${TEST_NAME} PROPERTIES TIMEOUT 120)
endfunction()

test_e2e(eventloop-stall)
test_e2e(headers)
test_e2e(runtime-err)
test_e2e(smoke)
Expand Down

0 comments on commit bed7e1a

Please sign in to comment.