Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.async by

In ClojureScript a "finally" is ignored if a string is thrown and the enclosing "try" is in a "go" block.

Example code:

(ns demo
(:require-macros
(link: cljs.core.async.macros :refer [go)]))

;; Prints: "in a finally"
(go (try (throw (ex-info "THROWN" nil)) (finally (println "in a finally"))))

;; Prints: "in a finally"
(go (try (throw (js/Exception. "THROWN")) (finally (println "in a finally"))))

;; Prints: "in a finally"
(go (try (throw (#js {})) (finally (println "in a finally"))))

;; Prints: "in a finally"
(try (throw "THROWN") (finally (println "in a finally")))

;; Prints: nothing
(go (try (throw "THROWN") (finally (println "in a finally"))))

5 Answers

0 votes
by

Comment made by: hubert

Also fails with:
org.clojure/clojure "1.8.0"
org.clojure/clojurescript "1.9.671"
org.clojure/core.async "0.3.443"

0 votes
by

Comment made by: hiredman

The issue is likely https://github.com/clojure/core.async/blob/17112aca9b07ebba6ce760ca01d117c24c80cc9a/src/main/clojure/cljs/core/async/impl/ioc_macros.clj#L861

If that is the case you will see this behavior when anything that isn't caught with js/Object (I know that is the case for strings and numbers, not sure what else). The finally isn't being skipped, the go block state machine is completely failing to handling the thrown thing, and completely bailing

0 votes
by

Comment made by: hubert

Sorry for the typo. The correct title should have been:
(CLJS) A "finally" in a "try" in a "go" block is skipped if a string is thrown.

0 votes
by

Comment made by: hiredman

the patch on https://dev.clojure.org/jira/browse/ASYNC-184 solves this by replacing the (catch js/Object ...) in the macro expansion with (catch :default ...)

0 votes
by
Reference: https://clojure.atlassian.net/browse/ASYNC-200 (reported by alex+import)
...