Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIDER connects to remote nrepl server instead of localhost #3730

Open
licht1stein opened this issue Aug 2, 2024 · 3 comments
Open

CIDER connects to remote nrepl server instead of localhost #3730

licht1stein opened this issue Aug 2, 2024 · 3 comments

Comments

@licht1stein
Copy link

licht1stein commented Aug 2, 2024

Steps to reproduce

  1. cider-connect-clj to a remote nrepl over SSH on port 65000
  2. Kill that repl.
  3. cider-connect-clj to local nrepl on port 65000 (same port as remote).

Expected behavior

CIDER is connected to local nrepl server.

Actual behavior

CIDER is connected to remote SSH nrepl from step 1.

Environment & Version information

CIDER version information

CIDER 1.15.0 (Cogne), nREPL 1.1.0
Clojure 1.12.0-beta1, Java 21.0.3

Lein / Clojure CLI version

Clojure CLI version 1.11.3.1463

Emacs version

GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin22.6.0, NS appkit-2299.70 Version 13.5.2 (Build 22G91)) of 2024-06-01

Operating system

Mac OS 13.5.2

JDK distribution

openjdk 21.0.3 2024-04-16
OpenJDK Runtime Environment Homebrew (build 21.0.3)
OpenJDK 64-Bit Server VM Homebrew (build 21.0.3, mixed mode, sharing)

@vemv
Copy link
Member

vemv commented Aug 2, 2024

Thanks for the report!

I might be wrong but it may be because we create a ssh tunnel that doesn't get destroyed after use, something like that.

@licht1stein
Copy link
Author

@vemv yes, when this bug happens there is a stray nrepl-tunnel process left. If I kill it with kill-process, the localhost connection works as expected.

@vemv
Copy link
Member

vemv commented Aug 3, 2024

Nice!

I've checked recent issues related to nrepl ssh tunnels and there wasn't one for this scenario specifically.

I'm not immediately sure if disposing of this tunnel would be a universally good idea or technically feasible.

(I'm not saying yes/no, just that I don't know).

The safest PR that we'd welcome is one that closed the tunnel after all connections using it were closed and there wasn't something like a sesman-restart in progress.

It still could use a defcustom so that the current behavior isn't changed - approximately like a feature flag.

e.g. defcustom cider-auto-close-ssh-tunnels nil, you'd set it to t, maybe we'd change the default after we'd consider it time-proven.

Of course, if all this was too much of a hassle, you could always just pick different ports for local/remote duties.

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

No branches or pull requests

2 participants