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

triple printlns #266

Closed
borkdude opened this issue Oct 5, 2015 · 9 comments
Closed

triple printlns #266

borkdude opened this issue Oct 5, 2015 · 9 comments

Comments

@borkdude
Copy link

borkdude commented Oct 5, 2015

I'm seeing thrice the output of println when I enable [cider/cider-nrepl "0.10.0-SNAPSHOT"] in my user profile. I didn't have this problem with 0.9.0.

In case it's useful, I'm using these other plugins in my profiles.clj:

        [jonase/eastwood "0.2.1"]
        [lein-kibit "0.1.2"]
        [lein-ancient "0.6.7"]
        [lein-cloverage "1.0.6"]
        [lein-bikeshed "0.2.0"]
        [lein-try "0.4.3"]
        [lein-plz "0.3.3"]

A look into my project.clj:

  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.122"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [compojure "1.4.0"]
                 [ring-server "0.4.0"]
                 [mysql/mysql-connector-java "5.1.35"]
                 [org.clojure/java.jdbc "0.3.7"]
                 [lib-noir "0.9.9"]
                 [yesql "0.4.2"]
                 [org.webjars/bootstrap "3.3.4"]
                 [org.webjars/jquery "1.11.1"] ;; needed by bootstrap
                 [org.webjars/jquery-throttle-debounce-plugin "1.1"]
                 [prismatic/schema "0.4.3"]
                 [digest "1.4.4"]
                 [secretary "1.2.3"]
                 [liberator "0.13"]
                 [cljs-http "0.1.35"]
                 [reagent "0.5.1"]
                 [wrap-verbs "0.1.1"]
                 [com.taoensso/timbre "4.0.1"]
                 [environ "1.0.0"]
                 [prismatic/dommy "1.1.0"]
                 [com.draines/postal "1.11.3"]
                 [com.novemberain/pantomime "2.6.0"]
                 [amazonica "0.3.24"]
                 [org.jsoup/jsoup "1.8.2"]
                 [optimus "0.17.1"]
                 [hiccup "1.0.5"]]

  :plugins [[lein-cljsbuild "1.0.6"]
            [lein-immutant "1.2.3"]
            [lein-figwheel "0.4.0"]
            [lein-environ "1.0.0"]
            [lein-auto "0.1.2"]]
@Malabarba
Copy link
Member

As per slack discussion, the first suspect is timbre. I'll have to try it out to figure out whether we're doing something wrong, but I'm very busy this week.

@Kungi
Copy link

Kungi commented Oct 7, 2015

I had a look into this problem and it seems to me that timbre is not the culprit. Even when I replace calls to timbre with println I also get the triple prints.

@Kungi
Copy link

Kungi commented Oct 7, 2015

It does not triple print when I run my application through the emacs cider repl. Only when I use lein repl.

@Malabarba
Copy link
Member

I had a look into this problem and it seems to me that timbre is not the culprit. Even when I replace calls to timbre with println I also get the triple prints.

Did you also remove the timbre dep completely?

It does not triple print when I run my application through the emacs cider repl. Only when I use lein repl.

What is the complete workflow in that case? Is it something like the following?

  1. lein repl on the command-line;
  2. Evaluate a println on this REPL.

Or is it like this?

  1. lein repl on the command-line;
  2. cider-connect in Emacs;
  3. Evaluate a println in a Clojure buffer.

@Kungi
Copy link

Kungi commented Oct 8, 2015

I was able to reproduce the bug in a quite minimal example:

https://github.com/Kungi/reproduce-triple-printlns

I run lein repl and type (go) without connecting cider-nrepl to it and open "http://localhost:3333/foo" in the browser and get a triple println.

@Malabarba
Copy link
Member

Thank you, this will be hugely useful. I expect I'll be able to fix it over the weekend.

@Malabarba
Copy link
Member

Ok, I see what's going on.
The middleware isn't actually bugging out, it's just that, when you start lein repl on a terminal, both the server's *out* and the client's *out* go to the same place (the terminal).
So you see all outputs in one place.

The reason you see 3 outputs instead of 2 is that lein repl apparently creates 2 sessions on the nREPL server, so you see 1 output from the server and 1 from each session. But I have no idea why two sessions are being created.

@Malabarba
Copy link
Member

In any case, I think the solution is to disable this automatic forwarding of the server out to every session, and instead only forward it to sessions created by cider.el (via some subscription request). Which is what @bbatsov originally suggested on the PR and I was too lazy to implement. =P

@bbatsov
Copy link
Member

bbatsov commented Oct 8, 2015

I'm in favour of this idea. :-)

Malabarba added a commit that referenced this issue Oct 17, 2015
Connected sessions must send a message with an "out-subscribe" op in
order to have server messages forwarded to them. The forwarded outs are then
sent as replies to this message (so it must be able to handle out).
Malabarba added a commit to clojure-emacs/cider that referenced this issue Oct 17, 2015
Malabarba added a commit that referenced this issue Oct 18, 2015
Connected sessions must send a message with an "out-subscribe" op in
order to have server messages forwarded to them. The forwarded outs are then
sent as replies to this message (so it must be able to handle out).
Malabarba added a commit that referenced this issue Oct 18, 2015
Connected sessions must send a message with an "out-subscribe" op in
order to have server messages forwarded to them. The forwarded outs are then
sent as replies to this message (so it must be able to handle out).
bbatsov added a commit that referenced this issue Oct 19, 2015
[Fix #266] Only forward server out to subscribed clients
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

4 participants