简体   繁体   中英

Cider repl has to be restarted if a promise is incorrectly used

I have the following:

(defn run [path]
  (.readFile fs path
             (fn [err data]
               
               (go
                 (let [model (<p! (.load coco-ssd))
                       predictions
                       (.detect model
                                

                                (tf/browser.toPixels
                                 (clj->js {:data (js/Uint32Array. data)
                                           :height 1000
                                           :width 1000})
                                 )
                                )]

                   (js/console.log "predictions " (<p! predictions))
                   )))))


Basically I'm using the tf/browser.toPixels which returns a promise where.detect expects a tensor. However, after this error occurs, I'm unable to load the function again in cider after making the edit, and have to restart the repl. When I try to reload after making the correction, I get the following:

ERROR: Unhandled REPL handler exception processing message {:ns main.core, :file /Users/prikshetsharma/Desktop/cvjs/src/main/core.cljs, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/print cider.nrepl.pprint/pr, :op eval, :column 1, :line 10, :id 208, :code (defn run [path]
  (.readFile fs path
             (fn [err data]
               
               (go
                 (let [model (<p! (.load coco-ssd))
                       predictions
                       (.detect model
                                

                                (tf/browser.toPixels
                                 (clj->js {:data (js/Uint32Array. data)
                                           :height 1000
                                           :width 1000})
                                 )
                                )]

                   (js/console.log "predictions " (<p! predictions))
                   )))))
, :nrepl.middleware.print/stream? [], :session 98ba8556-ae75-4a15-89f4-7df971632da7}
java.lang.AssertionError: Assert failed: (some? worker)
    at shadow.cljs.devtools.server.repl_impl$do_repl.invokeStatic(repl_impl.clj:19)
    at shadow.cljs.devtools.server.repl_impl$do_repl.invoke(repl_impl.clj:19)
    at shadow.cljs.devtools.server.nrepl_impl$do_cljs_eval.invokeStatic(nrepl_impl.clj:143)
    at shadow.cljs.devtools.server.nrepl_impl$do_cljs_eval.invoke(nrepl_impl.clj:131)
    at shadow.cljs.devtools.server.nrepl_impl$handle.invokeStatic(nrepl_impl.clj:216)
    at shadow.cljs.devtools.server.nrepl_impl$handle.invoke(nrepl_impl.clj:210)
    at shadow.cljs.devtools.server.nrepl$middleware$fn__7121.invoke(nrepl.clj:40)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at cider.nrepl$wrap_xref$fn__7491.invoke(nrepl.clj:473)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at cider.nrepl$wrap_slurp$fn__7311.invoke(nrepl.clj:95)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at cider.nrepl$wrap_out$fn__7403.invoke(nrepl.clj:297)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at nrepl.middleware.session$session$fn__6909.invoke(session.clj:272)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at cider.nrepl$wrap_enlighten$fn__7353.invoke(nrepl.clj:163)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at cider.nrepl$wrap_profile$fn__7411.invoke(nrepl.clj:306)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at nrepl.middleware.print$wrap_print$fn__6311.invoke(print.clj:234)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at cider.nrepl$wrap_resource$fn__7427.invoke(nrepl.clj:369)
    at nrepl.middleware$wrap_conj_descriptor$fn__6103.invoke(middleware.clj:16)
    at shadow.cljs.devtools.server.nrepl$start$fn__7152.invoke(nrepl.clj:138)
    at nrepl.server$handle_STAR_.invokeStatic(server.clj:18)
    at nrepl.server$handle_STAR_.invoke(server.clj:15)
    at nrepl.server$handle$fn__6946.invoke(server.clj:27)
    at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
    at clojure.lang.AFn.call(AFn.java:18)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

How to fix this?

This should be fixed in shadow-cljs version 2.10.15 .

The issue was that node crashes when any async code throws an exception. shadow-cljs did not correctly detect that crash and the nREPL session was stuck trying to talk to it. Now the crashed node process will be restarted when using node-repl . Your state will still be lost but at least the REPL stays usable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM