nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2019-05-01T07:18:25.041100Z

@bozhidar: Building nrepl from master I get a third behaviour from Calva. With my test script, using the same bencode and nrepl-client as Calva does, I get consistent behaviour across 0.5.3, 0.6.0, and 0.7.0-SNAPSHOT. But with Calva I get that behaviour only with 0.5.3. However, with 0.6.0 I get an ex message, with a stacktrace pointing me at the same file as you are pointing me at. So I’ll try to see if the nrepl code can help me figure out what I am doing wrong in Calva.

pez 2019-05-01T08:14:50.041500Z

I am not quite following the instructions at https://nrepl.org/nrepl/0.6.0/hacking_on_nrepl.html#_interactive_hacking

pez 2019-05-01T08:16:35.042700Z

One example of “not following” is: “make some changes and test them by starting new nREPL instances from the REPL and connecting to them to see how they are having”.

pez 2019-05-01T08:16:54.043200Z

How do I start new instances from the REPL?

pez 2019-05-01T08:18:32.044600Z

The example code/session there works. And I do start a server there, is that was is meant in the piece I quoted?

pez 2019-05-01T08:22:31.047300Z

As I am seeing the problems I have only in the CLJS REPL, I need some advice on how to do some interactive hacking towards that. I tried to promote/convert the repl by eval:ing (figwheel.main.api/cljs-repl :dev), which might or might not have worked, but don’t really have a clue how to go about it.

bozhidar 2019-05-01T09:13:58.047600Z

> How do I start new instances from the REPL?

bozhidar 2019-05-01T09:14:24.048100Z

There’s a start-server function in the nrepl.server namespace. I guess we should make this clearer.

bozhidar 2019-05-01T09:15:35.048300Z

> How do I start new instances from the REPL?

bozhidar 2019-05-01T09:15:51.048600Z

You also have to eval a bit of piggieback code for this to work.

bozhidar 2019-05-01T09:16:31.048800Z

https://github.com/nrepl/piggieback#usage

bozhidar 2019-05-01T09:16:40.049200Z

That’s how I typically test cljs interactions.

bozhidar 2019-05-01T09:17:32.049500Z

> Building nrepl from master I get a third behaviour from Calva. With my test script, using the same bencode and nrepl-client as Calva does, I get consistent behaviour across 0.5.3, 0.6.0, and 0.7.0-SNAPSHOT. But with Calva I get that behaviour only with 0.5.3. However, with 0.6.0 I get an ex message, with a stacktrace pointing me at the same file as you are pointing me at. So I’ll try to see if the nrepl code can help me figure out what I am doing wrong in Calva.

bozhidar 2019-05-01T09:18:31.050500Z

I think it’d be easiest for you to just modify that particular function with some debug info and see what’s going on there. What’s the third behaviour you’re getting on master?

bozhidar 2019-05-01T09:18:47.050700Z

> With my test script, using the same bencode and nrepl-client as Calva does, I get consistent behaviour across 0.5.3, 0.6.0, and 0.7.0-SNAPSHOT. But with Calva I get that behaviour only with 0.5.3.

bozhidar 2019-05-01T09:19:03.051200Z

How come you’re getting different behaviour if you’re using the same client? 🙂

pez 2019-05-01T09:34:59.053900Z

Yeah, it is a total mystery for me still, despite having trying to figure it out for a while now. But in my test script I force the communication to be synchronous, so it might well be that what goes wrong in Calva is to due with asynchronisity.

pez 2019-05-01T09:39:22.056700Z

With master I get the value and status (`done`) responses, but no out and no ex. (I shouldn’t say I don’t get those, I think I do, but that I somehow mess things up so that they are not delivered to my nrepl client.)

pez 2019-05-01T11:38:58.058700Z

Is there any particular profile I should start when jacking in to the nrepl project?

pez 2019-05-01T12:03:23.060400Z

I’m using the :master profile and it sort of works. But it seems that being jacked in to the same server as I am developing causes it to start recursing, so maybe I should go about it some other way…

bozhidar 2019-05-01T12:35:53.061Z

I’m simply using the dev profile and I’m connecting to the new servers I start afterwards.

bozhidar 2019-05-01T12:36:28.061800Z

Alternatively you can always make some changes, do lein install and use force the use of that build in profiles.clj.

pez 2019-05-01T13:47:29.062400Z

There is no dev profile as far as I can see.

dpsutton 2019-05-01T13:48:24.062800Z

oh sorry. nrepl 🙂

😃 1
pez 2019-05-01T13:52:18.065900Z

Leiningen does not complain when I say I want to use profile dev. And it seems to work. It also seems to me that I modify the server I am connected to when I evaluate forms in the source of that server. But what you are saying, @bozhidar, is that I should create a new server and connect to that one after modifying the source?

pez 2019-05-01T13:53:21.067100Z

My mind is actually quite blown away by connecting to the server I am modifying. Starting to realize what happened to Cantor…

😆 1
bozhidar 2019-05-01T13:54:32.068600Z

Yeah, you are in essence modifying the server you’re connected to, although certain things are set when the server starts and those can’t be modified on the fly. For those cases you need to start a new server from the updated code.

bozhidar 2019-05-01T13:54:50.069100Z

I know what you mean. This was super mind bending to me when I started working on CIDER back in the day.

pez 2019-05-01T13:58:52.070900Z

There is a lot of stuff in the msg map. Is there something in particular I should be looking for?

pez 2019-05-01T14:09:02.071700Z

When I add some printlns to the function I get StackOverflow when it runs…

pez 2019-05-01T14:54:42.071800Z

So, if I start the repl like so:

lein update-in :dependencies conj "[nrepl \"0.7.0-SNAPSHOT\"]" -- update-in :plugins conj "[cider/cider-nrepl \"0.21.1\"]" -- update-in "[:repl-options :nrepl-middleware]" conj "[\"cider.nrepl/cider-middleware\"]" -- repl 2> repl-errors.txt
It prints the following. (I do (printn (pr-str msg)) in that function).

pez 2019-05-01T14:56:15.072200Z

My terminal stars throwing away input when it grows to large so I catch stderr in a file. Where we find this error:

bozhidar 2019-05-01T15:06:09.073100Z

Hmm, a StackOverflow is usually in indication of some endless recursion. That’s weird.

bozhidar 2019-05-01T15:08:35.074800Z

Looking at the debug output it seems to be in order, but I assuming that’s from a Clojure session, right?

pez 2019-05-01T15:08:40.075Z

Yeah, I thought that was the Cantor thing first, but then I noticed that it happened before I connected anything. I’ve seen some other errors that indicate it is the pr-str.

pez 2019-05-01T15:10:49.075400Z

Looks like so. Including some traces of what else I have tried to do. 😃

pez 2019-05-01T15:18:27.076300Z

The session is before I do anything else. So, probably from starting the repl?

pez 2019-05-01T15:19:04.076700Z

It lasts a bit longer if I add :headless.

pez 2019-05-01T15:20:36.078300Z

Also when removing piggieback and other dependencies things crash if I try to reference that mysterious dev profile. So maybe that profile comes from some of those projects?

bozhidar 2019-05-01T15:30:46.079300Z

When I said dev profile I meant I was under the impression that’s what lein runs by default.

bozhidar 2019-05-01T15:31:21.080400Z

You can just select Clojure 1.10 or whatever for that matter.

pez 2019-05-01T15:32:07.081300Z

At least I can reproduce the problem using that nashorn cljs-repl and such. But if I try to peek at it, with that println, things blow up. Observation changes behaviour, or something.

pez 2019-05-01T15:37:21.082400Z

Anyone else that can repro the stackoerflow crash? Just tuck that (println "printing-transport msg: " (pr-str msg)) in there and run:

lein update-in :dependencies conj "[nrepl \"0.7.0-SNAPSHOT\"]" -- update-in :dependencies conj "[cider/piggieback \"0.4.0\"]" -- update-in :dependencies conj "[figwheel-sidecar \"0.5.18\"]" -- update-in :plugins conj "[cider/cider-nrepl \"0.21.1\"]" -- update-in "[:repl-options :nrepl-middleware]" conj "[\"cider.nrepl/cider-middleware\"]" -- update-in "[:repl-options :nrepl-middleware]" conj "[\"cider.piggieback/wrap-cljs-repl\"]" -- repl

pez 2019-05-01T16:04:15.083800Z

Actually it doesn’t matter what I print. (println "foo") results in the same SO.

pez 2019-05-01T16:51:18.087400Z

I'm thinking... Since my first impression was that things started to recurse. Maybe that is what is happening? When I collected the output in that log, it grew very fast. So, maybe the stuff I put in stdout here, gets fed back into the function somehow?

bozhidar 2019-05-01T17:13:05.088200Z

I don’t see how this can happen. It should act only on middleware responses.

bozhidar 2019-05-01T17:14:00.088700Z

But the SO is certainly indicative of some recursion. Go figure…

pez 2019-05-01T17:21:19.092400Z

SO happens in 0.5.3 if I add a println there too. I’m not knowledgeable enough to go figure about it. 😃 But I’m out of ideas on how to inspect the messaging… No.. maybe I can send it to a file…

pez 2019-05-01T17:32:03.093200Z

Yeah, spitting it out worked. Now dinner, will examine the output later. 😃

dpsutton 2019-05-01T17:38:53.093600Z

is it possible the middleware is set up to handle println and you are println-ing from the middleware giving you the SO?

pez 2019-05-01T17:39:46.094100Z

Sounds very possible to me.