Skip to content

Stream eval output as it is flushed - #14

Merged
yogthos merged 1 commit into
mainfrom
stream-eval-output
Oct 17, 2026
Merged

yogthos merged 1 commit into
mainfrom
stream-eval-output

Conversation

@burinc

@burinc burinc commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #13.

run-eval called the two-argument jolt.nrepl/evaluate, which captures *out* and returns it whole. So a long eval's output reached the client only when the eval finished, and anything it printed to *err* went to the server's terminal instead. It now passes evaluate's {:out f :err f} argument (jolt-lang/jolt#1157), so each flushed chunk goes out as an out or err message while the eval runs, the way upstream's session writers and jolt's built-in eval op do.

  • :jolt/min-version moves from 0.8.0 to 0.8.13, the first Jolt with that arity.
  • (when (seq out) ...) stays: :out comes back empty when streaming.
  • evaluate binds *capturing-thread* in both arities, so out-subscribe still doesn't echo an eval's own output a second time.
  • The README says output streams and why the floor is 0.8.13.

Tests

Two new tests in session_test.clj:

  • eval-output-streams-as-it-is-flushed: two printlns with a sleep between come back as two out messages, before the value.
  • eval-err-output-reaches-the-client: a println to *err* comes back as an err message.

Both fail on main and pass here. jolt -M:test on Jolt v0.8.22: 80 tests, 173 assertions, 0 failures (78 and 169 on main).

Timed against a real jolt nrepl-server using this branch, evaluating (dotimes [i 3] (println "tick" i) (Thread/sleep 1000)): the ticks arrive at 1, 1031 and 2036 ms and the value at 3041 ms. On main all three ticks arrive together at about 3010 ms.

run-eval called the two-argument jolt.nrepl/evaluate, which captures *out*
and returns it whole, so a long eval's output reached the client only when it
finished, and what it printed to *err* went to the server's terminal. It now
passes evaluate's {:out f :err f} (jolt 0.8.13 and later), so each flushed
chunk is sent as an out or err message while the eval runs, as upstream's
session writers do. :jolt/min-version moves to 0.8.13.

Fixes #13.
@burinc
burinc requested a review from yogthos October 17, 2026 05:30
@yogthos
yogthos merged commit 7efdd6c into main Oct 17, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

Eval output arrives all at once when the eval finishes

2 participants