core.async

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

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    org.clojure/clojure "1.8.0"
    org.clojure/clojurescript "1.9.229"
    org.clojure/core.async "0.3.442"

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

Activity

Hide
Uwe Hubert added a comment -

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

Show
Uwe Hubert added a comment - Also fails with: org.clojure/clojure "1.8.0" org.clojure/clojurescript "1.9.671" org.clojure/core.async "0.3.443"
Hide
Kevin Downey added a comment -

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

Show
Kevin Downey added a comment - 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
Hide
Uwe Hubert added a comment -

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.

Show
Uwe Hubert added a comment - 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.
Hide
Kevin Downey added a comment -

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

Show
Kevin Downey added a comment - 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 ...)

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: