diff options
author | Luca Casonato <hello@lcas.dev> | 2023-09-26 19:46:06 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 19:46:06 +0900 |
commit | c68650d53244ab5cc3cda232085a63cbb497f83b (patch) | |
tree | 5e537af29d8df0ac1a4b07e7fdf7fc5f524fd232 /cli/ops | |
parent | 6f87962a77f3dd409c71ff490fd5f36023b7b700 (diff) |
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.
Diffstat (limited to 'cli/ops')
-rw-r--r-- | cli/ops/testing.rs | 5 |
1 files changed, 5 insertions, 0 deletions
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<u8, AnyError> { + // Drop `fetch` connection pool at the end of a test + state.try_take::<reqwest::Client>(); + + // Generate a report of pending ops let report = { let after_metrics = match try_collect_metrics( state, |