clojure-emacs / clojure-emacs/cider

`[shadow-cljs]` output lost when repl-ing node http server

Open
#3,597 13 comments 1 reaction 0 assignees View on GitHub
bug ClojureScript help wanted
Dominant language
Emacs Lisp
Stars
3.7k
Forks
651
Avg merge
11h 6m
Merged PRs (30d)
33

Description

Hi, thanks as ever for CIDER - we live inside it and it's amazing. I'm digging deeper into `shadow-cljs` and am getting hung up because my print output is getting lost in this one specific case...

## Expected behavior

`println` produces output in the repl

## Actual behavior

I cannot find my `println` output anywhere (:

## Steps to reproduce the problem

When using `shadow-cljs` without CIDER, I eventually see the `"INSIDE"` printed:

```clojure
$ npx create-cljs-project node-server-test
[snip...]
----
Done. Actual project initialization will follow soon.
----
$ cd node-server-test/
$ npx shadow-cljs node-repl
shadow-cljs - config: /home/harold/node-server-test/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - server version: 2.26.2 running at http://localhost:9630
shadow-cljs - nREPL server started on port 36159
shadow-cljs - #4 ready!
cljs.user=> (defn handler [req res] (println "INSIDE") (.write res "Hello!") (.end res))
#'cljs.user/handler
cljs.user=> (require '["http" :as http])
nil
cljs.user=> (def s (http/createServer handler))
#'cljs.user/s
cljs.user=> (.listen s 8000)
#object[Server [object Object]]

;; Then, in another terminal:
$ curl localhost:8000
Hello!

;; And this is seen in the terminal repl:
cljs.user=> INSIDE
```

When doing the same thing in CIDER:

```clojure
(cider-jack-in-cljs)
shadow
node-repl
;; Connected to nREPL server - nrepl://localhost:42703
;; CIDER 1.9.0 (Barcelona), nREPL 1.0.0
;; Clojure 1.11.1, Java 11.0.21
;; Docs: (doc function-name)
;; (find-doc part-of-name)
;; Source: (source function-name)
;; Javadoc: (javadoc java-object-or-class)
;; Exit:
;; Results: Stored in vars *1, *2, *3, an exception in *e;
;; Startup: /usr/local/bin/npx shadow-cljs -d nrepl/nrepl:1.0.0 -d cider/cider-nrepl:0.41.0 -d cider/piggieback:0.5.3 server
;;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/node-repl))
;;
To quit, type: :cljs/quit
[:selected :node-repl]
shadow.user>
cljs.user> (defn handler [req res] (println "INSIDE") (.write res "Hello!") (.end res))
#'cljs.user/handler
cljs.user> (require '["http" :as http])
nil
cljs.user> (def s (http/createServer handler))
#'cljs.user/s
cljs.user> (.listen s 8000)
#object[Server [object Object]]
;; And now in the other terminal curl works works again (:
;; but the "INSIDE" print output is never seen :|
cljs.user>
```

## Environment & Version information

### Emacs version

27.1

### Operating system

```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
```

### JDK distribution

```
$ java --version
openjdk 11.0.21 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
```

---

Thanks in advance for your time and consideration, I am looking forward to developing this node app inside cider with shadow-cljs. :smile:

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the shadow-cljs node-repl case through CIDER and compare it with direct shadow-cljs output. Trace the CIDER, nREPL, and node-repl output path; done means println output from the HTTP callback is visible in the CIDER REPL.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, node.js
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.