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
[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"))))
org.clojure/clojure "1.8.0"
org.clojure/clojurescript "1.9.229"
org.clojure/core.async "0.3.442"
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
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.
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 ...)
Released in core.async 1.1.582