Clojurians
#cljs-dev
<
2016-09-01
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

xcthulhu13:09:19

Hey, so I have the following test that is failing for PhantomJS and Nashorn, but works fine for Safari, Firefox, Chrome, and SlimerJS:

(ns debug.promise-test
  (:require [cljs.test :refer-macros [is testing async deftest]])
  (:import [goog Promise]))

(deftest promise-test
  (testing "Can pull a value out of a Promise"
    (async done
      (-> (new Promise (fn [resolve] (resolve 1)))
        (.then (fn [val]
                 (is (= 1 val))
                 (done)))))))
This just hangs on PhantomJS and Nashorn. Is this a known thing?

darwin14:09:16

AFAIK PhantomJS does not have js/Promise, does goog.Promise polyfill it?

xcthulhu14:09:32

Yeah, that's the idea

xcthulhu14:09:09

I came at this bug playing with polyfills, but I'm giving you guys the minimal thing to reproduce the problem

xcthulhu14:09:40

The only reason for bothering with Promises is because I'm trying to wrap crypto.subtle, which handles everything in Promises. I want to fall-back to synchronous JS implementations and a polyfilled Promise-facade if that API isn't available.

xcthulhu14:09:47

It's probably a bug in goog.Promise - maybe the right thing to do is to drop it and use core.async channels?

darwin14:09:40

@xcthulhu I would try to test it with another polyfill implementation, for example taylorhakes/promise-polyfill worked for me

darwin14:09:01

under phantomJS

xcthulhu14:09:35

Okay, I'll give it a shot. Thanks a tonne!