Fork me on GitHub
#scittle
<
2023-01-20
>
pyrmont01:01:02

I’m trying to run a Scittle nREPL session with a bit of an unusual configuration. I have the server and my editor on one machine. However, the browser is running on another device (e.g. a phone). My editor is Neovim and I am using the Conjure plugin. When all the pieces are running locally, everything works fine. However, when the browser is on a different machine, there are problems. I think the first problem is that Scittle’s nREPL code is hard-coded to use "localhost" in the Websocket connection. If I instead input ws_nrepl = new WebSocket("ws://<address_of_editor>:1340/_nrepl"); directly into the JavaScript console on my browser, I can see in the network tab of Safari’s development tools that a WebSocket connection seems to be open. Moreover, if I evaluate code in my editor, nREPL messages are showing up as being received. However, it doesn’t appear as if my browser is sending anything back and Conjure never displays the response. Any ideas what could be the issue? Safari is not reporting any errors in the JavaScript console. Is the ws_nrepl value I’m creating in the console manually perhaps not what Scittle is trying to use?

pyrmont01:01:58

Oh, interesting. I started a Scittle session on the browser machine and I can see the nREPL messages with the results are being sent to that machine. I guess it must be that Scittle’s nREPL server is sending the results to localhost (i.e. my browser machine) rather than to the remote (i.e. my editor machine).

pyrmont02:01:48

Cool. I can make it work by changing the line in src/scittle/nrepl.cljs (https://github.com/babashka/scittle/blob/151ea479f3723ad68781b3d134e81bd1661d3f99/src/scittle/nrepl.cljs#L39) to use window.location.hostname. Will submit a PR.

pyrmont02:01:28

Ah, just found https://github.com/babashka/scittle/blob/main/doc/dev.md. I guess I’ll make an issue first.

Richie16:01:01

Is it easy to add selmer? I know it’s in babashka…

borkdude17:01:39

@rgkirch For that purpose I'd probably pick a JS library and add that to a <script></script> tag

Richie17:01:55

That’s a good point.

borkdude17:01:05

Selmer also doesn't work in CLJS I think

👍 2