From c68650d53244ab5cc3cda232085a63cbb497f83b Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 26 Sep 2023 19:46:06 +0900 Subject: fix(cli/test): clear connection pool after tests (#20680) This helps reduce flakes where a test starts an HTTP server and makes a request using fetch, then shuts down the server, then starting a new test with a new server, but the connection pool still has a "not quite closed yet" connection to the old server, and a new request to the new server gets sent on the closed connection, which obviously errors out. --- cli/ops/testing.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cli/ops') diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs index 8343fa36e..cb3788cdc 100644 --- a/cli/ops/testing.rs +++ b/cli/ops/testing.rs @@ -20,6 +20,7 @@ use deno_core::v8; use deno_core::ModuleSpecifier; use deno_core::OpMetrics; use deno_core::OpState; +use deno_runtime::deno_fetch::reqwest; use deno_runtime::permissions::create_child_permissions; use deno_runtime::permissions::ChildPermissionsArg; use deno_runtime::permissions::PermissionsContainer; @@ -348,6 +349,10 @@ fn op_test_op_sanitizer_finish( #[smi] op_id_host_recv_msg: usize, #[smi] op_id_host_recv_ctrl: usize, ) -> Result { + // Drop `fetch` connection pool at the end of a test + state.try_take::(); + + // Generate a report of pending ops let report = { let after_metrics = match try_collect_metrics( state, -- cgit v1.2.3