Skip to content

Fix what goes wrong around starting and finding servers - #33

Merged
bbatsov merged 7 commits into
mainfrom
jack-in-polish
Oct 20, 2026
Merged

bbatsov merged 7 commits into
mainfrom
jack-in-polish

Conversation

@bbatsov

@bbatsov bbatsov commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

A missing build tool says so instead of passing on sh's exec: lein: not found, --tool picks a server by the port file that tool writes, a port file for something that isn't nREPL gets given up on after 3s, a server that dies says how and takes its stale port file with it, and Ctrl-C during startup no longer gets reported as a failure.

A REPL in a project nested inside another still connects to the outer project's server, which is usually right for monorepos and Polylith workspaces, but now says so and points at neorepl server for the inner one. Discovery doesn't stop at the nearest project directory, since that breaks those layouts.

The server's command runs through sh, which ignores SIGINT for it, so a
missing lein came out as sh's "exec: lein: not found" and a server that
"ended before it started, with exit status 127". When the command can't
run, with sh's 127 or Java's exception on Windows, jack-in looks for the
tool on the PATH, with Windows' PATHEXT there, and says so if it isn't
there. It's left to the shell to find it otherwise, since sh expands a
~ in the PATH, and takes relative entries from the server's directory.
A port is free to be reused once the server that wrote the port file is
gone, and something listening there that doesn't speak nREPL never
answers describe, which connecting waited 10 seconds for. Finding a
server through its port file gives describe 3 seconds, far longer than
a server takes, busy or not, since nREPL answers each message on a
thread of its own.
neorepl repl --tool shadow-cljs connected to any server it found, a
Clojure one included, and only warned that --tool didn't apply, while
neorepl server refused to start a shadow-cljs server next to a Clojure
one, though they don't share a port file. Each tool now has the port
file its servers write, .shadow-cljs/nrepl.port for shadow-cljs and
.nrepl-port for the rest, and both commands go by the tool's only.
A server that crashed or got killed while neorepl server ran it made
neorepl exit 1 with no word why, and the REPL say only that it lost the
connection, and its port file stayed behind for the next command to try.
Both say the server's exit status now, unless neorepl's stopping it, and
when the server's gone, neorepl deletes the port file it wrote, if it
still has its port and nothing takes connections there. A project that
sets a port has the next server on it write the same port file.
Ctrl-C while a server starts has neorepl exit, stopping the server on
the way out, which ends it before it's up. When the thread waiting for
it got there before the JVM was done, it took that for the server
failing and said so. That's ::stopped now, which exits 130 quietly.
In a project inside another, a library in a monorepo with a deps.edn of
its own, say, the REPL connected to the outer project's server without a
word, where the classpath might be missing the inner project's deps. It
says so now, and that neorepl server starts a server for the inner one.
Connecting stays as it was, since the outer project's server is what a
monorepo or a Polylith workspace usually wants.

neorepl server, which won't start next to a server of its own project's,
checks that project's port file only, rather than its parents' too.
neorepl server runs until Ctrl-C or SIGTERM stops it, which leaves 130
or 143, while its help gave 0 for a server that ends fine and nothing
for those. The REPL without a terminal ends on Ctrl-C with 130 too.
@bbatsov
bbatsov merged commit f64376b into main Oct 20, 2026
18 checks passed
@bbatsov
bbatsov deleted the jack-in-polish branch October 20, 2026 07:36
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.

1 participant