-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
There are too many JS runtimes, don't know which to eval in. #314
Comments
Yeah this is a known problem and I don't have a clean solution yet. Everything for calling I have a very rough prototype available if you run
This kind of interaction is very easy to do in a normal REPL since it basically just starts a second REPL and waits for a number or |
@kurtharriger Found another way around this issue. You can close the shadow-cljs connection from a browser console if you already started two sessions.
And your REPL will pick the left-over runtime. |
Maybe a good interim solution would just be to have it always use the first connected repl for evaluation. I love being able to see the app I'm developing live on multiple browsers and mobile devices simultaneously but I wont trade the repl for it. |
Sorry to barge in, interesting discussion and I would love to know more about what limitation is there. Also, middleware is pluggable so you basically decide server side (client side is coming with side-loaders), which one to use, depending on the feature that your editor supports? If the editor does not support it, you can avoid loading that middleware. For instance you could have a In any case, many things are being addressed as we speak so this could be feasible soon. Actually the problem is that cider, for instance, does not have knowledge of a "shadow-cljs" connection so it cannot interpret its prompt - yet? |
@arichiardi the difference between nREPL and normal REPL is that the normal REPL is stream based. It is just a stream of characters. Text goes in, Text comes out. The REPL client is not expected to do anything special and everything typed by the user is just passed along. Any function used at the REPL can then hijack that stream if it wants to Read until it has received what it wants. It will then drop down back to the original REPL and continue on. This is fundamentally not possible with a message based protocol where each message is interpreted by a fixed set of middleware that the client has to be aware of. Ideally there would be a extra couple nREPL ops that deal with this kind of thing but there is not any as of yet. There are a bunch of other ongoing discussions about related topics. None with suitable solutions AFAICT. nrepl/nrepl#45 FWIW I have a working solution in the UI that is available when running the shadow-cljs server (default at http://localhost:9630). The REPL lets you directly select which runtime to connect to and has no issues with multiple browsers being connected. Of course that is not nREPL based but the basic ops required are just something to get a list of the connected runtimes and then some ID is passed along when starting a new REPL session. |
Yeah well message based protocols have all sorts of other advantages for editors of course, see for instance Server Language Protocols. As you said the ops should suffice and because you can provide your middleware as part of the shadow jar this would not need to be in |
You are missing my point. The message based protocols do have several advantages over a pure text stream but all features need to be supported by the client. So If you have concrete requests for some nrepl middleware ops that cider would like to use I'm happy to add them. |
@cdorrat your suggestions is reasonable and now the default in |
I have use case where it would be useful to have multiple connected runtimes:
Our module supports collaborative editing and thus testing requires multiple browser sessions. However, once more than one session connects I can no longer use the repl due to the above error.
I do realize if there are multiple sessions you generally don't need to evaluate an expression in both windows and there is ambiguity as to which return value to print in the response. In our case it would be fine if it just selected the first socket that connected, so my workaround is to start a repl manually in one session when/if I want one.
But, I have no way to switch sessions other than closing that browser window. Perhaps each session when connected could write a session id to the console. Then, by default, when multiple sessions are connected it is sent to the first session. If you want to switch, then perhaps you quit and rerun
nrepl-select
with an additional session id argument.It would would also be very useful in our case to broadcast a command to all connected sessions. This would make reproducing issues where multiple users typing concurrently a breeze. This might be awkward as a "repl" but perhaps a maybe another function like
(repl-send [session-id|:all] expression)
that would return a sequence of promises from each runtime.The text was updated successfully, but these errors were encountered: