(CLJS) A "finally" in a "try" in a "go" block is skipped in f a string is thrown.

Description

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"))))

Environment

org.clojure/clojure "1.8.0"
org.clojure/clojurescript "1.9.229"
org.clojure/core.async "0.3.442"

Activity

Show:
Alex Miller
March 31, 2020, 7:54 PM

Released in core.async 1.1.582

Kevin Downey
January 10, 2019, 12:21 AM

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 ...)

import
January 9, 2019, 10:46 AM

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.

Kevin Downey
July 13, 2017, 8:39 PM

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

Fixed
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Unassigned

Reporter

import

Labels