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

Printing in lazy-evaluated code sends output to babashka process instead of the nrepl client #36

Closed
llacom opened this issue Feb 12, 2021 · 4 comments

Comments

@llacom
Copy link
Contributor

llacom commented Feb 12, 2021

It seems I stumbled upon a bug: when using babashka as an nrepl server, printing something will correctly send the output to the nrepl client, however printing something inside something lazy-evaluated will instead send the result to babashka process itself:

user=> (mapv (fn [x] (println "It works" x) (inc x)) [10 20])
It works 10
It works 20
[11 21]
user=> (map (fn [x] (println "It prints in babashka process" x) (inc x)) [10 20])
(11 21)

image

Tested with

`--> bb --version
babashka v0.2.10
@borkdude
Copy link
Contributor

@bbatsov Could you point me to how this is handled in nrepl/nrepl? Do you change the root binding of *out*, or do you force lazy sequences before sending?

@bbatsov
Copy link

bbatsov commented Feb 12, 2021

I think the relevant code starts here https://github.com/nrepl/nrepl/blob/master/src/clojure/nrepl/middleware/interruptible_eval.clj#L81 There's no special handling for lazy sequences, but we do rebind the output streams in the evaluation logic.

1 similar comment
@bbatsov
Copy link

bbatsov commented Feb 12, 2021

I think the relevant code starts here https://github.com/nrepl/nrepl/blob/master/src/clojure/nrepl/middleware/interruptible_eval.clj#L81 There's no special handling for lazy sequences, but we do rebind the output streams in the evaluation logic.

borkdude added a commit to babashka/babashka that referenced this issue Feb 12, 2021
@borkdude
Copy link
Contributor

Fixed.

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

3 participants