Repository navigation
Fix what goes wrong around starting and finding servers - #33
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A missing build tool says so instead of passing on sh's
exec: lein: not found,--toolpicks 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 serverfor the inner one. Discovery doesn't stop at the nearest project directory, since that breaks those layouts.