-
Notifications
You must be signed in to change notification settings - Fork 408
Zone.js conflicts with Bluebird #455
Comments
this also causes problems when you use sequelize (which uses bluebird) with angular universal. |
Unfortunately, it is not enough to call Bluebird |
I was caught off-guard by this. I wanted to include Angular 2 on a page already utilizing some Bluebird methods. My options are to put Angular in an iFrame or rewrite the Bluebird promises. Neither are great. |
Is there any solution yet to this problem? We are suffering the same fate as we are trying to use ngUpgrade with a existing ng1 application which is using Bluebird. |
@lorenzodallavecchia How do you apply your patch in a SystemJS environment? Could you help me with that? |
@andreasrueedlinger The project that I am migrating from Angular 1 does not use any module loader yet: it is just including the angular UMD bundles as browser globals ( Eventually I am planning to adopt a module loader (still undecided between System.js and WebPack). |
@lorenzodallavecchia Thanks for your help. It seems to be a bit more complex in my case! I am using electron with sequelize and angular2. For angular I am using systemjs but for the native modules I have to load it using the native module loader. The problem is now that sequelize does not use the global |
@andreasrueedlinger you can try this one, we use sequelize too, and we use this code to make zone work with sequelize. The newest comment is the working code. |
Nice, thanks! |
I'll make a pull request to make a bluebird patch just like the sequelize zone patch but without import shimmer.js. |
Hi thanks a lot for the patch, @JiaLiPassion . Unfortunately with current Zone 0.7.8 it doesnt work for us. The patch is loaded and patching the Bluebird, but we still get the error on startup of our angular2 app.
We need to execute this line to get rid of it:
but is this really the wanted behaviour?
EDIT:
|
@christophmegusta , can you provide a reproduce repo or plunker? I would like to find out why zone.js complain
And could you tell me more about
a reproduce code or repo will help, thank you. |
I searched the very first fix that I was using, based on var originalScheduler = Promise.setScheduler(function(fn) {
originalScheduler(Zone.current.wrap(fn));
}); The idea is to wrap the task callback in the current Zone. If I recall correctly, the problem was that sometimes the scheduler function is called outside of every zone (in the root zone that is). As a result The new fix in #655 is using Unfortunately I have not much spare time for building a proper repro. It should probably involve a |
@lorenzodallavecchia , yeah, in my first fix, I patch _then to do the work, maybe that solution will resolve the issue, but first could you give some code sample about how to reproduce the outside(root) zone case? |
@lorenzodallavecchia, @JiaLiPassion I can't get With native Promise one should see "Works" in Electron window, whereas with bluebird Promise it should display "Does not work". Console log should have "resolved" in it to prove that promises still work. Edit: Just to clarify, I want to assign |
I'm including Zone 0.6.21 in a project that also uses Bluebird as one of the first steps for using Angular 2. Unfortunately, there does not seem to be a clean way for having the two libraries work together.
Bluebird is more than a "Promise shim", since it replaces the
Promise
implementation entirely, with a more performant one, while also adding many utilities both to thePromise
constructor and its prototype.Promise
constructor, loosing all utilities and the internal implementation of Bluebird. This basically defeats the purpose of including Bluebird in the first place.Zone.assertZonePatched
that Angular 2 calls will fail, since thePromise
constructor is no longer the one from Zone.Curently I can work around the problem by including Bluebird after Zone and then manually patching each function in the Bluebird API.
If you are interested, this Gist shows the full code.
As you can see it is pretty hacky and I would better go without it if it was possible.
Is there a particular reason for Zone introducing an entire
Promise
constructor instead of just wrappingthen
,catch
and other methods?The text was updated successfully, but these errors were encountered: