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

CIDER hanging with newer babashka.nrepl #45

Closed
giuliano108 opened this issue Sep 17, 2021 · 10 comments
Closed

CIDER hanging with newer babashka.nrepl #45

giuliano108 opened this issue Sep 17, 2021 · 10 comments

Comments

@giuliano108
Copy link

I'm having issues getting CIDER to talk to babashka 0.6.1 nREPL . CIDER hangs afer evaluating the first form. When using babashka 0.4.1 everything works fine. I tried multiple versions of CIDER / babashka.

In Emacs, I've set nrepl-log-messages to t, causing CIDER to log all the nREPL messages sent/received.

With bb 0.4.1 , I see CIDER sending 2 eldoc ops (id=6 and id=7), folloed by an eval (id=8). bb immediately replies no-eldoc to id=6 and id=7 . id=8, as expected gets the result of the eval.

With bb 0.6.1 , bb doesn't reply to the 2 eldoc ops or the eval. Ops 6, 7 and 8 go unanswered. I double checked with tcpdump to confirm that the responses are missing from the "wire" as well.

You should be able to see the full side-by-side logs here:

https://gist.github.com/giuliano108/47edecde5f64d964a596ffda1d2ba907/revisions?diff=split#diff-eda0f6fe7e39e7b95b3db19a55a8f05c2f3e3c84d72039dc945aa9a17fb582cbL92

@borkdude
Copy link
Contributor

@giuliano108 It would be useful if you can detect the most recent bb that still worked before 0.6.1:

https://github.com/babashka/babashka/releases

@borkdude
Copy link
Contributor

borkdude commented Sep 17, 2021

It's still working for me with CIDER but I haven't upgraded CIDER for a while. Could you also specify your CIDER version?

@borkdude
Copy link
Contributor

For the record, I'm using cider 1.2.0-snapshot (from July).

@borkdude
Copy link
Contributor

Now upgraded to the newest 1.2.0-snapshot released on 14th of September, still works. Do you have some code you are running for reproduction?

@giuliano108
Copy link
Author

Now upgraded to the newest 1.2.0-snapshot released on 14th of September, still works. Do you have some code you are running for reproduction?

I tried both 1.2.0-snapshot and now I'm on 1.1.1. With a clj file open in Emacs, I'm running bb nrepl-server, then cider-connect. At that point, evaluating (+ 1 1) in the cider-repl buffer, without doing anything else, was causing CIDER to hang.

I'm saying "was" because as I was trying every bb release in turn, I stopped being able to reproduce the issue... 😞

The same operation that was getting no response before (eldoc for the -> symbol) is now being regularly answered.

I'm sorry for wasting your time, I'll close the issue and will come back with better data if I come across it again in the future.

Thanks for babashka!

(-->
  id         "6"
  op         "eldoc"
  session    "e7fe485f-e0cc-4b6a-8514-a3293af8f99f"
  time-stamp "2021-09-17 21:59:17.901560000"
  ns         #("workday" 0 7 (fontified nil help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
  sym        "->"
)
(<--
  id         "6"
  session    "e7fe485f-e0cc-4b6a-8514-a3293af8f99f"
  time-stamp "2021-09-17 21:59:18.074796000"
  eldoc      nil
  name       nil
  ns         "clojure.core"
  status     ("done")
  type       "function"
)

@giuliano108
Copy link
Author

@borkdude, I've managed to reproduce the issue outside of CIDER, by using the "official" nrepl/nrepl.

This is the repro script:

(require '[clojure.pprint :refer [pprint]])
(require '[nrepl.core :as nrepl])

(with-open [conn (nrepl/connect :port 1667)]
  (let [client (nrepl/client conn 1000)]
    (println "### 1 - Sending")
    (time
      (-> client
          ;; setting a :ns other than "user" triggers a different behaviour
          ;; depending on the version of babashka
          ;; bb 0.5.0 -> all OK
          ;; bb 0.5.1 and newer -> both nrepl/message calls time out
          (nrepl/message {:op "eldoc" :sym "->>" :ns "somens"})
          doall
          pprint))
    (println "### 1 - Received\n")

    (println "### 2 - Sending")
    (time
      (-> client
          (nrepl/message {:op "eval" :code "(+ 1 1)" :ns "user"})
          doall
          pprint))
    (println "### 2 - Received\n")))

(System/exit 0)

I run it with:

clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "LATEST"}}}' -M nrepl_test.clj

bb version 0.5.0 causes the script to generate the output below (nothing unexpected):

### 1 - Sending
({:id "f129d10f-7b3f-488f-bb41-86383f7112dc",
  :session "none",
  :status ["no-eldoc" "done"]})
"Elapsed time: 41.194489 msecs"
### 1 - Received

### 2 - Sending
({:id "01baf091-397c-4484-b0ab-e893a8d168d4",
  :ns "user",
  :session "none",
  :value "2"}
 {:id "01baf091-397c-4484-b0ab-e893a8d168d4",
  :session "none",
  :status ["done"]})
"Elapsed time: 18.036323 msecs"
### 2 - Received

Newer babashkas, including 0.6.1 cause the script to hang/timeout waiting on bb's nREPL server. That's the same behaviour I was seeing in CIDER.

### 1 - Sending
()
"Elapsed time: 1024.387576 msecs"
### 1 - Received

### 2 - Sending
()
"Elapsed time: 1005.941852 msecs"
### 2 - Received

@giuliano108 giuliano108 reopened this Sep 29, 2021
@borkdude
Copy link
Contributor

Thank you!

@borkdude
Copy link
Contributor

borkdude commented Oct 5, 2021

I can reproduce this with executing your script against v0.5.0 vs v0.6.0:

docker run --rm -p 1667:1667 babashka/babashka:0.6.0 bb nrepl-server 0.0.0.0:1667
### 1 - Sending
()
"Elapsed time: 1016.894966 msecs"
### 1 - Received

### 2 - Sending
()
"Elapsed time: 1003.025573 msecs"
### 2 - Received

borkdude added a commit that referenced this issue Oct 5, 2021
@borkdude
Copy link
Contributor

borkdude commented Oct 5, 2021

Found the issue. What OS are you using with bb? I can provide a binary for testing later today.

@borkdude
Copy link
Contributor

borkdude commented Oct 5, 2021

Here is a linux binary:

https://22909-201467090-gh.circle-artifacts.com/0/release/babashka-0.6.2-SNAPSHOT-linux-amd64.tar.gz

In case you need a different OS, let me know.

@borkdude borkdude closed this as completed Oct 5, 2021
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

2 participants