From 3e24f22054e064116dc6a4f6481d598a51b7bd9f Mon Sep 17 00:00:00 2001 From: Sabine Schmaltz <6594573+sabine@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:15:28 +0100 Subject: [PATCH 1/2] Warn users when RPC connection retry loop is triggered When dune attempts to forward a build request to an existing dune process but cannot establish an RPC connection, it silently retries indefinitely. This adds a warning message to inform users what is happening and how to resolve the issue by deleting _build/.lock if no other dune process is actually running. Signed-off-by: Sabine Schmaltz <6594573+sabine@users.noreply.github.com> --- bin/rpc/rpc_common.ml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bin/rpc/rpc_common.ml b/bin/rpc/rpc_common.ml index 1bbbba44569..4069a27893b 100644 --- a/bin/rpc/rpc_common.ml +++ b/bin/rpc/rpc_common.ml @@ -77,11 +77,31 @@ let establish_connection_exn () = let establish_connection_with_retry () = let open Fiber.O in let pause_between_retries_s = 0.2 in + let warned = ref false in let rec loop () = establish_connection () >>= function | Ok x -> Fiber.return x | Error _ -> + if not !warned + then ( + warned := true; + let lock_file = Path.Build.(relative root ".lock") in + let lock_held_by = Dune_util.Global_lock.Lock_held_by.read_lock_file () in + let pid_suffix = + match lock_held_by with + | Dune_util.Global_lock.Lock_held_by.Unknown -> "" + | Pid_from_lockfile pid -> sprintf " (pid: %d)" pid + in + User_warning.emit + [ Pp.textf + "Another dune instance%s is currently running. Waiting for it to finish..." + pid_suffix + ; Pp.textf + "If you're certain no other dune process is running, you can resolve this by \ + deleting: %s" + (Path.Build.to_string lock_file) + ]); let* () = Dune_engine.Scheduler.sleep ~seconds:pause_between_retries_s in loop () in From 8b3b1d1f7fc7032d81b11a9fec659336d9368f39 Mon Sep 17 00:00:00 2001 From: Sabine Schmaltz <6594573+sabine@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:21:05 +0100 Subject: [PATCH 2/2] I think we were actually waiting to connect to it, not for it to finish Signed-off-by: Sabine Schmaltz <6594573+sabine@users.noreply.github.com> --- bin/rpc/rpc_common.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/rpc/rpc_common.ml b/bin/rpc/rpc_common.ml index 4069a27893b..515c364e7a8 100644 --- a/bin/rpc/rpc_common.ml +++ b/bin/rpc/rpc_common.ml @@ -95,7 +95,7 @@ let establish_connection_with_retry () = in User_warning.emit [ Pp.textf - "Another dune instance%s is currently running. Waiting for it to finish..." + "Another dune instance%s is currently running. Waiting connect to it..." pid_suffix ; Pp.textf "If you're certain no other dune process is running, you can resolve this by \