Rendering exceptions in REPL can cause an IllegeArgumentException
lread opened this issue · comments
Reported on Slack, fleshed out by me.
Version
current master
Platform
Tested on JVM Clojure using emacs and cider nrepl
Symptom
Exception rendering in REPL can suffer an IllegalArgumentException: Multiple methods in multimethod 'simple-dispatch'....
Reproduction
Given fiddle.clj
:
(ns fiddle
(:require [etaoin.api :as e]))
(e/with-chrome driver
(e/go driver 'this-should-be-a-string))
Evaluate the 1st form, then the 2nd form.
Cider will try to render the exception produced by the 2nd form.
Actual behavior
Instead of a rendered exception from form 2, I see the following exception in my cider emacs REPL buffer:
ExceptionInfo throw+: {:response {:sessionId "c592dd1d942f5e293e8e91ec7d2b2a5a", :status 61, :value {:message "invalid argument\n (Session info: chrome=108.0.5359.94)\n (Driver info: chromedriver=108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016}),platform=Linux 6.0.6-76060006-generic x86_64)"}}, :path "session/c592dd1d942f5e293e8e91ec7d2b2a5a/url", :payload {:url this-should-be-a-string}, :method :post, :type :etaoin/http-error, :port 36489, :host "127.0.0.1", :status 200, :webdriver-url nil, :driver {:type :chrome, :host "127.0.0.1", :port 36489, :url "http://127.0.0.1:36489", :locator "xpath", :capabilities {:loggingPrefs {:browser "ALL"}}, :args ("chromedriver" "--port=36489"), :process {:proc #object[java.lang.ProcessImpl 0x37f79a75 "Process[pid=152775, exitValue=\"not exited\"]"], :exit nil, :in #object[java.lang.ProcessImpl$ProcessPipeOutputStream 0x13c9467e "java.lang.ProcessImpl$ProcessPipeOutputStream@13c9467e"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x1695fc6b "java.lang.ProcessBuilder$NullInputStream@1695fc6b"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x1695fc6b "java.lang.ProcessBuilder$NullInputStream@1695fc6b"], :prev nil, :cmd ["chromedriver" "--port=36489"]}, :session "c592dd1d942f5e293e8e91ec7d2b2a5a"}} slingshot.support/stack-trace (support.clj:201)
ERROR: Unhandled REPL handler exception processing message {:op stacktrace, :nrepl.middleware.print/stream? 1, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/buffer-size 4096, :nrepl.middleware.print/options {:right-margin 80}, :session ad4bacfe-1884-47d1-b5ee-3d256e9a161c, :id 148}
java.lang.IllegalArgumentException: Multiple methods in multimethod 'simple-dispatch' match dispatch value: class babashka.process.Process -> interface clojure.lang.IPersistentMap and interface clojure.lang.IDeref, and neither is preferred
at clojure.lang.MultiFn.findAndCacheBestMethod(MultiFn.java:178)
at clojure.lang.MultiFn.getMethod(MultiFn.java:150)
at clojure.lang.MultiFn.getFn(MultiFn.java:154)
at clojure.lang.MultiFn.invoke(MultiFn.java:229)
at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
at clojure.pprint$pprint_map$fn__10500$fn__10502.invoke(dispatch.clj:100)
at clojure.pprint$pprint_map$fn__10500.invoke(dispatch.clj:100)
at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:99)
at clojure.pprint$pprint_map.invoke(dispatch.clj:94)
at clojure.lang.MultiFn.invoke(MultiFn.java:229)
at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
at clojure.pprint$pprint_map$fn__10500$fn__10502.invoke(dispatch.clj:100)
at clojure.pprint$pprint_map$fn__10500.invoke(dispatch.clj:100)
at clojure.pprint$pprint_map.invokeStatic(dispatch.clj:99)
at clojure.pprint$pprint_map.invoke(dispatch.clj:94)
at clojure.lang.MultiFn.invoke(MultiFn.java:229)
at clojure.pprint$write_out.invokeStatic(pprint_base.clj:194)
at clojure.pprint$write$fn__9735.invoke(pprint_base.clj:233)
at clojure.pprint$write.invokeStatic(pprint_base.clj:233)
at clojure.pprint$write.doInvoke(pprint_base.clj:197)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at cider.nrepl.pprint$pprint.invokeStatic(pprint.clj:47)
at cider.nrepl.pprint$pprint.invoke(pprint.clj:42)
at clojure.lang.Var.invoke(Var.java:390)
at nrepl.middleware.print$wrap_print$fn__1204$print__1206.invoke(print.clj:224)
at cider.nrepl.middleware.stacktrace$analyze_cause$pprint_str__6137.invoke(stacktrace.clj:319)
at cider.nrepl.middleware.stacktrace$analyze_cause.invokeStatic(stacktrace.clj:331)
at cider.nrepl.middleware.stacktrace$analyze_cause.invoke(stacktrace.clj:314)
at cider.nrepl.middleware.stacktrace$analyze_causes$fn__6144.invoke(stacktrace.clj:348)
at clojure.core$map$fn__5583$fn__5584.invoke(core.clj:2734)
at clojure.core$take_while$fn__5634$fn__5635.invoke(core.clj:2893)
at clojure.lang.Iterate.reduce(Iterate.java:79)
at clojure.core$transduce.invokeStatic(core.clj:6803)
at clojure.core$into.invokeStatic(core.clj:6819)
at clojure.core$into.invoke(core.clj:6807)
at cider.nrepl.middleware.stacktrace$analyze_causes.invokeStatic(stacktrace.clj:347)
at cider.nrepl.middleware.stacktrace$analyze_causes.invoke(stacktrace.clj:339)
at cider.nrepl.middleware.stacktrace$handle_stacktrace.invokeStatic(stacktrace.clj:356)
at cider.nrepl.middleware.stacktrace$handle_stacktrace.invoke(stacktrace.clj:353)
at clojure.lang.Var.invoke(Var.java:385)
at cider.nrepl$wrap_stacktrace$fn__3361.invoke(nrepl.clj:432)
at nrepl.middleware$wrap_conj_descriptor$fn__969.invoke(middleware.clj:16)
at nrepl.middleware.print$wrap_print$fn__1204.invoke(print.clj:234)
user>
Expected behavior
I would expect to see the exception produced by the 2nd form rendered nicely in emacs.
Diagnosis
@borkdude diagnosed this on slack to be due to babashka.process.pprint
ns not being loaded.
Action
We'll do a require on babashka.process.pprint
to support rendering REPL exceptions properly.
We assume that this will be harmless for etaoin usage.
Did a little test, should only be requiring babashka.process.pprint
for jvm Clojure and not babashka.