{"action":"created","issue":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/650","labels_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/650/labels{/name}","comments_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/650/comments","events_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/650/events","html_url":"https://github.com/petkaantonov/bluebird/issues/650","id":87603828,"number":650,"title":"interaction between setScheduler, longStackTraces, and async trampoline","user":{"login":"metamatt","id":313893,"avatar_url":"https://avatars.githubusercontent.com/u/313893?v=3","gravatar_id":"","url":"https://api.github.com/users/metamatt","html_url":"https://github.com/metamatt","followers_url":"https://api.github.com/users/metamatt/followers","following_url":"https://api.github.com/users/metamatt/following{/other_user}","gists_url":"https://api.github.com/users/metamatt/gists{/gist_id}","starred_url":"https://api.github.com/users/metamatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamatt/subscriptions","organizations_url":"https://api.github.com/users/metamatt/orgs","repos_url":"https://api.github.com/users/metamatt/repos","events_url":"https://api.github.com/users/metamatt/events{/privacy}","received_events_url":"https://api.github.com/users/metamatt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-12T04:33:23Z","updated_at":"2015-06-12T09:10:37Z","closed_at":null,"body":"I'm trying to use Bluebird alongside Angular 1.4 to replace Angular's $q ([a la this suggestion](https://github.com/angular/angular.js/issues/6697)).\r\n\r\nI found that actions taken in a promise.then handler don't always get digested unless I trigger a digest cycle. I stepped around the Bluebird code a bit to see how the result of setScheduler was used, and it seems to be honored only if `async._trampolineEnabled` is true. And if I'm reading the code correctly, use of [`Promise.longStackTraces()`](https://github.com/petkaantonov/bluebird/blob/c464fa1c5f031e2f9c0e7d42835fd810fa13fb31/src/debuggability.js#L143) in Chrome [automatically disables the trampoline](https://github.com/petkaantonov/bluebird/blob/c464fa1c5f031e2f9c0e7d42835fd810fa13fb31/src/async.js#L22).\r\n\r\nI'm new to this project so don't know the history with the trampoline, the Async abstraction, etc but I think I agree with the [spin in the README.md on the sync build](https://github.com/petkaantonov/bluebird#what-is-the-sync-build): don't use it (i.e. things are best with the trampoline enabled).\r\n\r\nAlso I noticed that calling `Promise.enableTrampoline()` implicitly re-enables the default scheduler, so if `Promise.setScheduler()` had previously been set, now it won't be.\r\n\r\nIs it possible to make these features (long stack traces and setScheduler) work better together? (I see #542 but I don't know what the issue was there and the link is broken so it's hard to piece together the story starting now).\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/petkaantonov/bluebird/issues/comments/111422960","html_url":"https://github.com/petkaantonov/bluebird/issues/650#issuecomment-111422960","issue_url":"https://api.github.com/repos/petkaantonov/bluebird/issues/650","id":111422960,"user":{"login":"petkaantonov","id":829734,"avatar_url":"https://avatars.githubusercontent.com/u/829734?v=3","gravatar_id":"","url":"https://api.github.com/users/petkaantonov","html_url":"https://github.com/petkaantonov","followers_url":"https://api.github.com/users/petkaantonov/followers","following_url":"https://api.github.com/users/petkaantonov/following{/other_user}","gists_url":"https://api.github.com/users/petkaantonov/gists{/gist_id}","starred_url":"https://api.github.com/users/petkaantonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petkaantonov/subscriptions","organizations_url":"https://api.github.com/users/petkaantonov/orgs","repos_url":"https://api.github.com/users/petkaantonov/repos","events_url":"https://api.github.com/users/petkaantonov/events{/privacy}","received_events_url":"https://api.github.com/users/petkaantonov/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T09:10:37Z","updated_at":"2015-06-12T09:10:37Z","body":"we discussed offline and this could be done by implementing invoke like this\r\n\r\n```js\r\nthis.schedule(fn);\r\n```\r\n\r\nand invokeLater like this\r\n\r\n```js\r\nthis.schedule(function() {\r\n    setTimeout(fn, 100);\r\n});\r\n```\r\n\r\nwhen trampoline is disabled"}}