clojure-emacs / cider-nrepl

A collection of nREPL middleware to enhance Clojure editors with common functionality like definition lookup, code completion, etc.
https://docs.cider.mx/cider-nrepl
676 stars 176 forks source link

`middleware.out` may stop working after a reconnect? #878

Open vemv opened 4 months ago

vemv commented 4 months ago

I'm using CIDER 1.13.1 (Santiago) and log4j2 (deps.edn) and my CIDER session disconnected because it lost access to the network. Is there any way to get the repl buffer reattached to the log output?

https://clojurians.slack.com/archives/C0617A8PQ/p1716294437574019

This happens after a reconnection via cider-connect.

vemv commented 4 months ago

It might be similar to https://github.com/clojure-emacs/logjam/issues/16 (easy fix)

timvisher commented 4 months ago

I'll see if I can produce a minimal repro case.

timvisher commented 4 months ago

👋 👋 👋 @vemv. This is decently minimal. Hope it helps. :)

https://github.com/timvisher/cider-middleware-out-repro-issue-878

vemv commented 4 months ago

Thanks, Tim!

Hope we can jump to it one of these days.

timvisher commented 3 months ago

I was able to reproduce this using logback as well which is documented as working in the manual. It's up in https://github.com/timvisher/cider-middleware-out-repro-issue-878 (commit). Cheers! :)

vemv commented 3 months ago

Thanks!

Just as additional context, why do you need to reconnect with a certain frequency?

It seems fairly unusual to me to have a repl connection dropped.

timvisher commented 3 months ago

I'm connecting from my laptop which sleeps and wakes with some regularity. The process I'm running takes days to complete (currently) and I want to be monitoring its progress while doing other things.

Make sense? It's a bit of strange use case even in my career but doesn't seem wildly undesirable.

timvisher commented 3 months ago

I've observed that any logs that are created after reconnect do get captured in the REPL buffer. And if I use a future to manage the long running process then I can cancel it and recreate it and new logs are captured. This is less than ideal obviously but an interesting data point. This is all in the repro repo.

vemv commented 3 months ago

Thanks!

The process I'm running takes days to complete (currently) and I want to be monitoring its progress while doing other things.

In case it helps, for anything that is production-like, we don't particularly recommend having the cider-nrepl middleware stack activated.

(It's perfectly possible to have a bare nREPL server running, without cider-nrepl, and have a CIDER connected to it. It will have a more bare-bones functionality)

The reason is that cider-nrepl is generally aimed for dev-time activities and its side-effects are not guaranteed to not intefere with production matters.

With all this said, we should certainly aim to fix these. Personally I can't exactly promise when - PRs welcome as well.

timvisher commented 3 months ago

The process I'm running takes days to complete (currently) and I want to be monitoring its progress while doing other things.

In case it helps, for anything that is production-like, we don't particularly recommend having the cider-nrepl middleware stack activated.

(It's perfectly possible to have a bare nREPL server running, without cider-nrepl, and have a CIDER connected to it. It will have a more bare-bones functionality)

The reason is that cider-nrepl is generally aimed for dev-time activities and its side-effects are not guaranteed to not intefere with production matters.

With all this said, we should certainly aim to fix these. Personally I can't exactly promise when - PRs welcome as well.

Very much understood. :)