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

janet-netrepl -l VALUE and near-immediate client disconnection #160

Closed
sogaiu opened this issue Dec 25, 2023 · 0 comments
Closed

janet-netrepl -l VALUE and near-immediate client disconnection #160

sogaiu opened this issue Dec 25, 2023 · 0 comments

Comments

@sogaiu
Copy link
Contributor

sogaiu commented Dec 25, 2023

When trying the --library / -l functionality of janet-netrepl:

 -l, --library VALUE                         Load libraries in the repl as with the janet -l flag

I noticed that specifying something for VALUE that lives under JANET_PATH leads to a client connection being ended right after successful establishment.

The following is a demo.


Suppose spork is installed (so spork lives under JANET_PATH and janet-netrepl is available).

Start server:

$ janet-netrepl -l spork
Starting networked repl server on 127.0.0.1, port 9365...

Start client (note the exiting apparent from the second prompt):

$ janet-netrepl -c
$

Observe output for server:

client [127.0.0.1:9365] connected
closing client [127.0.0.1:9365]

Some investigation revealed that (dyn :syspath)'s value was nil within the handler function for spork/netrepl.janet's server function.

The following diff seemed to yield better results here:

diff --git a/spork/netrepl.janet b/spork/netrepl.janet
index 2556bf5..1986183 100644
--- a/spork/netrepl.janet
+++ b/spork/netrepl.janet
@@ -125,11 +125,13 @@
   (default port default-port)
   (eprint "Starting networked repl server on " host ", port " port "...")
   (def name-set @{})
+  (def syspath (dyn :syspath))
   (net/server
     host port
     (fn repl-handler [stream]
 
       # Setup closures and state
+      (setdyn :syspath syspath)
       (var name "<unknown>")
       (var last-flush 0)
       (def outbuf @"")

Not sure if that's a good way to address things, but the "immediate client disconnect" situation described above was resolved.

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

1 participant