[NREPL-46] nREPL crashes when required more than one time with :reload-all Created: 21/Dec/13 Updated: 12/Jan/15 Resolved: 12/Jan/15
|Reporter:||Alex Fowler||Assignee:||Chas Emerick|
Irrelevant, but the provided test case project is for CounterClockWise on Eclipse. Although it should run just fine with vanilla lein.
When the namespace "clojure.tools.nrepl.server" is required more than once with :reload-all option, nREPL crashes. Accrding to current info it occures because some protocol instances get re-evaluated and are no longer the same JVM classes as they were before reload-all.
Steps to reproduce the bug in CCW:
Upon trying CCW autocompetion, the following exception occures, what might give some hint as to why:
Exception in thread "nREPL-worker-2" java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'clojure.tools.nrepl.transport/Transport found for class: clojure.tools.nrepl.middleware.pr_values$pr_values$fn$reify__1283
|Comment by Chas Emerick [ 19/Aug/14 8:56 PM ]|
Confirmed. Using lein repl (though you're right that the particulars of the tooling shouldn't matter):
Not sure if it's the protocol or the types that are implicated (or both), but resolving this is going to be unpleasant.
|Comment by Chas Emerick [ 19/Aug/14 8:57 PM ]|
Couple of questions:
|Comment by Alex Fowler [ 25/Aug/14 9:34 AM ]|
Well, in my case I have a project which is required to often reload various namespaces because they are updated in the background. If it happens that any of the namespaces refer to nrepl, the thing crashes.
The error happens due to implementation problems and is not "a correct error" from the POV of Clojure language so it is better to be fixed. However, of course, in the real world it could be rather hard to do so..
Chas, could you please explain more about the no-ops approach? Do you mean it is possible to somehow force loading nrepl just once?
|Comment by Chas Emerick [ 25/Aug/14 10:20 AM ]|
Yes, there are ways to prevent the re-definition of types and protocols, but I'd like to avoid doing so. It's a hack, and would be an impediment to developing nREPL itself.
Actually, you should be able to accomplish the same thing more easily in your project: rather than require nREPL namespaces in the ns form, use a top-level require form, wrapped in a suitable conditional to determine if nREPL has been loaded yet:
|Comment by Chas Emerick [ 12/Jan/15 8:43 AM ]|
Not going to make any changes to nREPL in connection with this. :reload-all should be considered dangerous in general, IMO.