Skip to content

Resolving Promises Within Workers #119

@Weblors

Description

@Weblors

This is my code:

            let p = new Parallel(businessChunks);

            let result = yield p.map(businessIds => {
                'use strict';

                const Promise = require('bluebird');
                const BusinessReport = require(process.cwd() + '/bin/dataExport/business');

                return Promise.map(
                    businessIds,
                    businessId => {
                        let businessReport = new BusinessReport(businessId, {
                            qbConnectionString: 'address',
                            botId: 'id'
                        });

                        return businessReport.generate();
                    },
                    {
                        concurrency: process.env.TASK_CONCURRENCY
                    }
                );
            });

As you can see, within each worker I'm doing lots of asynchronous stuff using bluebird's promise library and I want the result if that to be returned. But the output gives me four promise objects. How do I get this to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions