(CLJS) promise-chan in ClojureScript is broken

Description

promise-chan in ClojureScript does not seem to work. In Clojure on the JVM, the code below produces the expected result.

Example:

(ns hush-vendor-cljs.example
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :refer [promise-chan <! >!]]))

(def p (promise-chan))

(def go-1 (go (let [r (<! p)] (println "got value on promise-chan::" r))))

(def go-2 (go (let [r (<! p)] (println "got value on promise-chan::" r))))

(go (>! p 1))
;This prints only once in ClojureScript, should be twice. It works on JVM Clojure (prints twice).
;=> got value on promise-chan:: 1

Environment

Google Chrome 48.0.2564.109 (64-bit) Mac OS X El Capitan 10.11

Attachments

2

Activity

Show:

Bogdan Bugarschi May 24, 2017 at 10:39 PM

yey thx

David Nolen May 24, 2017 at 4:49 PM

Bogdan, thanks for the feedback. I'll apply your test patch.

Bogdan Bugarschi May 23, 2017 at 5:22 PM

Fix looks good as far as i can tell, but i think you should update the tests to account for this bug as well. There already is a test for that case, it's just not correct. it's "put on promise-chan fulfills all pending takers" from tests.cljs. basically the go block around the test needs to moved inside (see my 0002 patch for the tests).

David Nolen May 19, 2017 at 8:04 PM

I believe I've resolved the issue on master as of this commit https://github.com/clojure/core.async/commit/52f6bc19b599623a247539311e81336c5979b19f. Please test master and report back here. Thanks everyone.

Completed

Details

Assignee

Reporter

Approval

Triaged

Priority

Created February 13, 2016 at 11:58 PM
Updated May 25, 2017 at 10:41 PM
Resolved May 25, 2017 at 10:41 PM