0

I am using node version 16 and following all documented steps. Still worker thread is not working.

`

const addPaymentApi = async (req) => {
    const { payload, adminId } = req.body;
    logInfo(`Request to Create payment!`, {
        adminId
    });

    const createPaymentResponse = await composeResult(
        (response) => {
            const worker = new Worker("../workers/bulk-add-payment-api.worker.js");
            worker.on("message", (data) => {
                //update response table
            })
            return Result.Ok(response);
        },
        () => db.create(new CreateBulkUploadResponse(adminId))
    )({ payload, adminId });
    return respond(
        createPaymentResponse,
        `Payments processed Sucessfully!`,
        `Not Able to process payments!`,
    );
}

Code inside worker file is not getting executed

I tried every possible solution. I want to create a worker thread and perform CPU extensive task.

2
  • Is code inside (response) => { } executed? Commented Dec 16, 2022 at 23:00
  • Yes it is executing. Commented Dec 19, 2022 at 6:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.