[ALOY-1604] iOS 10.0: Bluebird Promise not firing 'then' if Alloy is used.

GitHub Issuen/a
ResolutionNot Our Bug
Resolution Date2018-03-05T21:48:09.000+0000
Affected Version/sn/a
Fix Version/sn/a
Labelsalloy, bluebird, promises
ReporterHugo Ramos Freire Neto
AssigneeFeon Sua Xin Miao


When I use Alloy for something, bluebird promise not firing 'then' on iphone 5s with OS 10.0. If I use OS 11.0, it works normally. If I use SDK 6.x, it works normally on all OS versions. To Reproduce: 1. Create a new Project 2. Download bluebird.min.js at https://github.com/petkaantonov/bluebird/releases 3. Rename to bluebid.js and past on lib folder. 4. Write on app/alloy.js:
Alloy.Globals.test = 'test';
3. Write on index.js:
var Promise = require('bluebird');

var test = new Promise(function (resolve){


test.then(function (){

	console.log('not working!!');

5. Run os Iphone 5s simulator with OS 10.0. The ('not working!!') log doesn't work. If I remove the (Alloy.Globals.test) log, then promise is fired and the The ('not working!!') log works.




  1. Hans Knöchel 2018-02-10 Titanium SDK 7.1.0 and later will support built-in promises, so you won't need any external library for it anymore. Therefore I would propose to not address this but use the built in solution in the next release. Since we won't have a release before 7.1.0, this will be the earliest fix date anyway. Are you okay with that? P.S.: You can try out the ES6 / promises support today using the master branch (appc ti sdk install -b master). Thanks!
  2. Sharif AbuDarda 2018-02-11 Hello [~hrfn], Can you get back to us testing with the master release? Thanks.
  3. David Benko 2018-02-11 Hello, I'm having this issue as well. I have a large app and we have other libraries that depend on bluebird. We use bluebird specific methods such as Promise.mapSeries that are not present the native implementation. The native implementation also have very bad stack traces, and bluebird provides has a complete stack when exceptions occur. Unfortunatelly we cant switch to native promises because of those reasons
  4. Hans Knöchel 2018-02-13 JavaScriptCore on iOS 11 supports Promises built-in (even without transpilation / Babel), which you are basically overriding. Since SDK 7, we enable JavaScriptCore by default and you can disable with <use-js-core-framework>false</use-js-core-framework> in the <ios/> section of the tiapp.xml. Please also confirm this only happens with Alloy and not classic apps.
  5. Hugo Ramos Freire Neto 2018-02-21 false Not solved the problem. The problem only happens on iOS 10. The Problem only happens when I use Alloy. On Classic app works fine, because Alloy is not called. ex: Alloy.Globals.test. I've tested on master branch, and the problem persists.
  6. Arthur Padilha 2018-02-21 This issue is happening in my apps too. It's critical because I use Bluebird everywhere in my app and it's happening when my app is used on iOS 10 devices. I use Alloy too.
  7. Feon Sua Xin Miao 2018-02-22 Attached a classic app that has the same issue. In app.js at line 2, 21 and 32, the same module is called but produces different out come. [~amukherjee], let me know if you and anyone is able to verify this.
  8. Feon Sua Xin Miao 2018-02-22 [~hrfn], if you replace console.log(Alloy.Globals.test); with say console.log('####'); the promise listener registered with .then() won't get called either. So I'm not exactly sure what's the purpose of the reproduce step #4. This might be related to the promise library, it seems like a scheduling issue, and I'm able to reproduce with a classic app. You can workaround is by using setTimeout:
       var test = new Promise(function (resolve){
       	setTimeout(function() { resolve(); }, 0);
  9. Hugo Ramos Freire Neto 2018-02-22 I've tested right now, if I use console.log('####'); instead console.log(Alloy.Globals.test); it work's for me. And on classic app works for me too.
  10. David Benko 2018-02-28 Any thoughts on why this is happening on iphone OS 10 only? Does it have anything different?
  11. Feon Sua Xin Miao 2018-03-05 According to [~eharris], removing this commit fixes the issue https://github.com/petkaantonov/bluebird/commit/b8e580c52504457f618018c5e434abb72548a3b8. Looks like an issue with the promise library itself.
  12. Ewan Harris 2018-03-06 To expand upon Feons comment here's how I arrived at that conclusion - I searched the Bluebird issue tracker on the GitHub for any known issues on iOS, I found [this](https://github.com/petkaantonov/bluebird/issues/1022) which appeared to be a similar issue, albeit closed as fixed - We know this worked in SDK 6, one major change around JavaScript usage from SDK 6 to 7 was that the on device JavaScriptCore framework became the default. - Seeing as how the fix for the above issue is using the JS Engines promise implementation, it seemed possible to me that this bug was due to the JavaScriptCore Promise implementation on certain iOS versions pre 11.0 (from my tests, I could see the issue down to iOS 8) - I ran with <use-jscore-framework>false</use-jscore-framework> in my tiapp, which forces the app to use TiJSCore (i.e pre-7 behavior), the issue was not seen - I removed the changes in [the fix](https://github.com/petkaantonov/bluebird/commit/b8e580c52504457f618018c5e434abb72548a3b8), this fixed the issue So the issue here appears to be due to Bluebird delegating to the native Promise implementation when possible. This isn't seen when using TiJScore (pre 7 behaviour, false behaviour), because it doesn't have a native Promise implementation. But there is good news, as there's a few ways to fix this! 1. As stated in the original issue on GitHub you can call [Promise.setScheduler](http://bluebirdjs.com/docs/api/promise.setscheduler.html) to override the schedule, which should fix the problem. In Feons classic example changing test.js to the below fixes the issue for me, and also adding the setScheduler call in the Alloy sample fixes it for me too
        var Promise = require('bluebird');
        Promise.setScheduler(function(fn) {
            setTimeout(fn, 0);
        function Test(str) {
            console.log('@@@@@@@@@@ ', Promise);
            var test = new Promise(function (resolve){
            test.then(function (){
        module.exports = Test;
    2. Fork bluebird, remove the changes in the aforementioned commit, build the libraries yourself and use those. 3. Set <use-jscore-framework>false</use-jscore-framework>, to use TiJSCore. But I do not recommend this way as you'll just be deferring this problem for a little while as TiJSCore is I believe is due for removal in SDK 8

JSON Source