Skip to content

fix(rpc): report connection failures without a backtrace - #15700

Draft
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:push-tsklwszsyvtt
Draft

fix(rpc): report connection failures without a backtrace#15700
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:push-tsklwszsyvtt

Conversation

@Alizter

@Alizter Alizter commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Description

Format Unix errors returned while connecting an RPC client as user-facing
reasons instead of embedding their captured backtraces. Unexpected non-Unix
exceptions continue to include their backtraces.

A connection to a stale socket now reports:

Error: failed to connect to RPC server unix:path=_build/.rpc/dune
Reason: connect(): Connection refused

Related Issue and Motivation

A watch server killed with SIGKILL cannot remove _build/.rpc/dune.
Connecting to the abandoned socket returns ECONNREFUSED, which is an expected
user-facing failure but was previously printed with an internal backtrace.

Fixes #15676.

Testing

  • Updated the regression test introduced in test(rpc): cover connecting to a killed watch server #15675.
  • ./dune.exe runtest test/blackbox-tests/test-cases/watching/rpc-connect-after-server-killed.t
  • ./dune.exe runtest test/expect-tests/dune_rpc
  • ./dune.exe build @check @fmt
  • Manually reproduced the failure through both dune rpc ping and
    dune monitor, and verified that restarting the watch server still works.

No changelog or documentation update is needed for this routine error-message
improvement.

A client connecting to a watch server that was killed without cleaning
up its RPC socket gets ECONNREFUSED. This was reported as a user error
with a backtrace. Format Unix errors from the connect call as a reason
instead, keeping the backtrace for unexpected exceptions.

Fixes ocaml#15676

Signed-off-by: Ali Caglayan <alizter@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPC clients connecting to an abandoned socket should fail gracefully

1 participant