-
Notifications
You must be signed in to change notification settings - Fork 408
Patched bluebird does not provide data to promise chain #1112
Comments
@jrabbe, I will check this one, could you post a |
You can chain bluebird promises, yes, but the value from the callbacks (each of the
Promise.resolve()
.then(() => console.log(Date.now()))
.then(() => Promise.delay(1000))
.then(() => console.log(Date.now())); The difference between the two log statements should be roughly 1,000 ms, without the patch to return a promise mentioned in the original description, they both print almost immediately.
Promise.resolve('a string')
.then(value => {
return { value };
}).then(result => {
console.log(result.value); // <-- will crash with "TypeError: cannot property 'value' of undefined"
}); I will try and create a formal test case later today if I have time, but these two cases should definitely fail with the existing bluebird patch. |
@jrabbe, yes, you are right, your fix is correct, I will add test cases and fix this one, thank you very much for the research. |
…urn a Bluebird Promise
…urn a Bluebird Promise
…urn a Bluebird Promise
…urn a Bluebird Promise
Hi @mhevery, I think this issue still persists. I use knex.js that uses bluebird internally. in my code i have
error without patching bluebird is knex error |
@Coobaha, could you provide a reproduce repo? Thanks. |
It's not exactly the same issue i have in my project but seems to be related |
If I add manually "catch" to zone-bluebird apis to patch it works
|
Just started investigating the upgrade of a large application based on AngularJS to Angular. This application relies on Bluebird as its global promise object and uses webpack as its module loader. The prescribed solutions mentioned in #455 were unsuccessful, as the promises from webpack kept resolving to
undefined
instead of the relevant view and controller content.After investigation the reason for these failures seem to be the way the promises are resolved in the bluebird patch function. The callbacks for
.then
,.spread
, and.finally
are patched to schedule the invocation as a zone.js micro task. However, the result from the callbacks is never made available to bluebird breaking the promise chain. Specifically, the call tozone.scheduleMicroTask
returns a task, but that task is never saved, and the result of the task invocation is not passed back to Bluebird.To solve this I have patched the Bluebird patch to return promises from the callbacks, ensuring Bluebird waits for the values to resolve when the micro task is invoked, and allowing the values to continue into the promise chain.
The text was updated successfully, but these errors were encountered: