dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
frank 2016-05-26T06:42:18.000357Z

I can't seem to get any of the (dirac! commands to work šŸ˜ž

frank 2016-05-26T06:48:40.000360Z

nvm it works now :simple_smile:

frank 2016-05-26T07:19:13.000361Z

After running (dirac! :join), trying to eval anything gives me an error like this:

dirac.lib.nrepl-tunnel-server    | [NREPLTunnelServer#1 of [NREPLTunnel#1]] Received an error from client [WebSocketServerClient#1] :
                                   |  {:err
                                   |  "Unable to unserialize forwarded nREPL message:\n {:ns \"frontend.core\", :file \"*cider-repl localhost*\", :op \"eval\", :column 15, :line 54, :pprint-fn #function[cider.nrepl.middleware.pprint/wrap-pprint-fn/fn--24400/fn--24402], :id \"15\", :code \"1\\n\"}",
                                   |  :op :error,
                                   |  :id "01100e8b-53ed-4680-a514-83c9458097fc"}

frank 2016-05-26T07:20:41.000363Z

I'm seeing this in both cider and the lein repl

frank 2016-05-26T07:21:00.000364Z

I'm guessing this is because of the cider-nrepl middleware?

danielcompton 2016-05-26T09:19:54.000366Z

Removing all other middleware is a good first step

frank 2016-05-26T13:08:28.000367Z

šŸ˜•

frank 2016-05-26T13:41:30.000368Z

that did work!

frank 2016-05-26T13:42:37.000369Z

most emacs users have cider-nrepl middleware in their ~/.lein/profiles.clj though, so it would be hard to convince my team to remove it šŸ˜ž

2016-05-26T14:51:23.000371Z

@frank: Iā€™m pretty sure we will figure a way how to make it work

2016-05-26T15:05:30.000372Z

ok, looking at the code, the whole problem is that the message is unserialisable on client side because of that :pprint-fn key, not sure why they include this key there in a form which is not portable background info: when you switch your session into joined dirac session (meaning joined to some ā€œsourceā€ session), I send all incoming nrepl messages (e.g. ā€œeval" requests) to your joined session to client-side to be processed by Dirac devtools, is can implement the nrepl message directly if appropriate or send it back to the ā€œsourceā€ session for actual processing. In any case I need to unserialise the message on client side to look at the operation and act appropriately.

frank 2016-05-26T15:09:02.000375Z

I see

frank 2016-05-26T15:09:16.000376Z

can the key be ignored?

2016-05-26T15:09:41.000377Z

yes, we can easily make a hack to accommodate your case, but I would like to think about it more and find more general solution

frank 2016-05-26T15:10:00.000378Z

:thumbsup:

frank 2016-05-26T15:10:28.000379Z

dissoc all vals that aren't strings?

2016-05-26T15:10:37.000380Z

I use read-string on client side, maybe I could use some other function which would skip unserializable keys or something, I donā€™t want to implement some nrepl message transformation on server side, if possible

frank 2016-05-26T15:10:46.000381Z

ah

2016-05-26T15:10:48.000382Z

cannot do dissoc prior parsing it

2016-05-26T15:11:03.000383Z

I get a string and I need to parse it on client side

frank 2016-05-26T15:11:12.000384Z

gotcha

2016-05-26T15:11:38.000385Z

this is the current implementation: https://github.com/binaryage/dirac/blob/master/src/implant/dirac/implant/intercom.cljs#L260-L264

2016-05-26T15:12:52.000389Z

btw that error logging could tell you more about the problem, it gets logged into Diracā€™s console (the console you can open from Dirac DevTools window)

frank 2016-05-26T15:13:32.000392Z

ah ok I didn't look there

2016-05-26T15:14:18.000393Z

would be nice to look there to confirm my theory, I donā€™t really have cider stuff set up and running

frank 2016-05-26T15:17:01.000395Z

I think all that's needed is to add something like [cider/cider-nrepl "0.11.0"] to :plugins in project.clj and the issue should reveal itself in the lein repl

2016-05-26T15:17:42.000396Z

ok, will try it

frank 2016-05-26T15:18:07.000397Z

but I will try too šŸ™‚

frank 2016-05-26T15:21:08.000398Z

@darwin: I didn't see it in my dirac window

2016-05-26T15:21:57.000399Z

hmm, that means that this read-string returned nil without throwing? https://github.com/binaryage/dirac/blob/master/src/implant/dirac/implant/intercom.cljs#L262

frank 2016-05-26T15:22:41.000401Z

sounds like it

2016-05-26T15:23:22.000402Z

Iā€™m looking into cljs.reader/reader and clojure.edn/reader, not clear if any of them will be able to parse the message and somehow skip unparseable bits

2016-05-26T15:23:54.000403Z

as I said I would like to solve it on client-side if possible

2016-05-26T15:25:02.000404Z

or maybe even cljs.tools.reader?

frank 2016-05-26T15:27:56.000405Z

ahh I think I understand what you've been saying now

2016-05-26T15:30:55.000406Z

looking at the docs of cljs.reader/read-string and it does not thow by default, just silently returns nil, so that is why we are not getting that error log

2016-05-26T15:31:39.000407Z

throwing can be enabled, that would be an improvement, but that would not solve our problem at hand

2016-05-26T15:55:42.000408Z

@frank: I was able to reproduce the issue, just looking at the devtools console and that read-string really throws: https://dl.dropboxusercontent.com/u/559047/hmm-throws.png note that ā€œtroubles unserializing message"

2016-05-26T15:56:00.000410Z

you were probably looking at wrong console.

frank 2016-05-26T15:56:03.000411Z

hm I didn't see that

frank 2016-05-26T15:56:11.000412Z

oh yeah I was looking at dirac console

2016-05-26T15:56:23.000413Z

this is console of the devtools window, not the console of your appā€™s page window

frank 2016-05-26T15:56:33.000414Z

ooooh

frank 2016-05-26T15:56:33.000415Z

right

frank 2016-05-26T15:56:53.000416Z

I keep forgetting I can do that

2016-05-26T15:57:09.000417Z

I have there more messages because Iā€™m running the dev build, maybe yours would look different

2016-05-26T15:58:09.000418Z

I will be able to fix it on client side, at least with tools.reader, we can specify our own "tag parsers"

2016-05-26T15:58:30.000419Z

so I will be able to parse it and turn all unknown tags to nil values

2016-05-26T15:59:04.000420Z

also a workaround for you could be to exclude wrap-pprint-fn middleware: https://github.com/clojure-emacs/cider-nrepl#via-leiningen

2016-05-26T15:59:52.000422Z

btw. that :plugins approach didnā€™t work for me, I had to go :dependencies route and cofigure :repl-options myself

2016-05-26T16:00:27.000423Z

for some reason adding just cider-nrepl as plugin didnā€™t work with my project configuration somehow

frank 2016-05-26T16:00:58.000424Z

ah

2016-05-26T22:18:49.000425Z

@frank: realized that on nrepl (server) side checking for this makes more sense, but after implementing it on client side, so I kept both: https://github.com/binaryage/dirac/commit/e98d8b92877a62c828fffad392e57c26e0693650 https://github.com/binaryage/dirac/commit/7b4b4e1f76a6a21c598015b3050350b29ce621bc

šŸ‘ 1