简体   繁体   English

如果 promise 使用不正确,则必须重新启动 Cider repl

[英]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.基本上我使用的是 tf/browser.toPixels 它返回一个 promise where.detect 需要一个张量。 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.但是,发生此错误后,我无法在进行编辑后再次在苹果酒中加载 function,并且必须重新启动 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 .这应该在shadow-cljs版本2.10.15中修复。

The issue was that node crashes when any async code throws an exception.问题是当任何异步代码抛出异常时node崩溃。 shadow-cljs did not correctly detect that crash and the nREPL session was stuck trying to talk to it. shadow-cljs没有正确检测到该崩溃,并且 nREPL session 被卡在试图与之交谈。 Now the crashed node process will be restarted when using node-repl .现在使用node-repl时崩溃的node进程将重新启动。 Your state will still be lost but at least the REPL stays usable.您的 state 仍然会丢失,但至少 REPL 仍然可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Clojure和ClojureScript REPL(emacs +苹果酒+靴子) - Clojure & ClojureScript REPL (emacs + cider + boot) 让cider-scratch在Clojurescript REPL中进行评估 - Let cider-scratch evaluate in Clojurescript REPL 将苹果酒连接到Luminus + CLJS Figwheel repl - Connect Cider to Luminus +CLJS Figwheel repl 在emacs中无法在Cider中启动figwheel REPL - Can't start figwheel REPL inside Cider in emacs boot-clj:苹果酒劫持后浏览器替换 - boot-clj: browser repl after cider-jack-in 为什么 CIDER 的 REPL 有时以“shadow.user&gt;”开头,而在其他情况下以“cljs.user&gt;”开头? - Why CIDER's REPL some times start as "shadow.user>" and in others it starts as "cljs.user>"? 没有应用程序连接到 REPL 服务器 - No application has connected to the REPL server 为什么 CIDER 的 REPL 的行为不一致? 如何理解 shadow-cljs 的错误信息“No available JS runtime”? - Why is CIDER's REPL's behavior inconsistent? How to understand shadow-cljs' error message "No available JS runtime"? 为什么 cider-jack-in-cljs 检索错误时“shadow-cljs cljs-repl app”仍在工作? - Why is "shadow-cljs cljs-repl app" still working while cider-jack-in-cljs is retrieving an error? 如何在苹果酒中运行自动化 cljs 测试? - How to run automate cljs tests in cider?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM