From 687a9395889c2653449c0453e35a12b889c56519 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Mon, 8 May 2023 09:52:56 +0200 Subject: fix(ext/http): Ensure Deno.serve works across --watch restarts (#18998) Fixes #16699 and #18960 by ensuring that we release our HTTP `spawn_local` tasks when the HTTP resource is dropped. Because our cancel handle was being projected from the resource via `RcMap`, the resource was never `Drop`ped. By splitting the handle out into its own `Rc`, we can avoid keeping the resource alive and let it drop to cancel everything. --- cli/util/file_watcher.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cli/util') diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 05415f2a6..1ad5e9ba0 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -304,6 +304,13 @@ where } loop { + // We may need to give the runtime a tick to settle, as cancellations may need to propagate + // to tasks. We choose yielding 10 times to the runtime as a decent heuristic. If watch tests + // start to fail, this may need to be increased. + for _ in 0..10 { + tokio::task::yield_now().await; + } + let mut watcher = new_watcher(watcher_sender.clone())?; consume_paths_to_watch(&mut watcher, &mut paths_to_watch_receiver); -- cgit v1.2.3