Bluebird promise.all 不遵守结果顺序

Bluebird promise.all not respecting result order

我正在使用最新的稳定版 bluebird:

"bluebird": "~3.4.0",

并使用以下代码:

Promise.all([ParticipantsService.retrieveActiveParticipantsFromTheLocalDb(),
    EventService.retrieveActiveEventsFromTheLocalDb(),
    HeatService.retrieveActiveHeatsFromTheLocalDb()]).then(
    function (results) {
        var namedResults = {participants: results[0], events: results[1], heats: results[2]};
        return res.render('runners/runners', namedResults);
    }).catch(
    function (err) {
        winston.error('Failed to retrieve participants and or event details', err);
        return res.send(err);
    });

我希望 namedResults 的元素顺序总是与承诺数组的顺序相匹配,但事实并非如此!我每次的顺序都不一样。

我之所以这样假设是因为它在 bluebird 的文档中是这么说的:http://bluebirdjs.com/docs/api/promise.all.html 除非我读错了...

有人能帮忙吗?

谢谢

您应该可以为此使用蓝鸟的 Promise.props():

Promise.props({
  participants: ParticipantsService.retrieveActiveParticipantsFromTheLocalDb(),
  events: EventService.retrieveActiveEventsFromTheLocalDb(),
  heats: HeatService.retrieveActiveHeatsFromTheLocalDb()
}).then(res.render.bind(res, 'runners/runners'))