How to Avoid Warnings in Pipedream for a Node.js Workflow without Async Calls Using MixPanel Library?

This topic was automatically generated from Slack. You can find the original thread here.

I have a nodejs workflow action that doesn’t make any async calls. What is the correct way of returning to avoid getting a warning in pipedream that the code hasn’t completed executing? If it helps I’m using the MixPanel library which doesn’t expose promises and promisify doesn’t work with a number of the operations.

You’ll have to wrap the Mixpanel library manually with Promises in order to “hold” the execution until it’s completed.

Here’s an example with promisifying the AWS S3 SDK which only exposes callbacks instead of promises:

import AWS from 'aws-sdk'


// Create a presigned POST request for uploading files to S3
export default defineComponent({
  props: {
    Bucket: { 
      type: 'string',
      description: "The bucket where the object should be uploaded to."
    },
    Key: {
      type: "string",
      description: "The object filename, a.k.a. the Key."
    },
    options: {
      type: object,
      description: "Other AWS S3 options."
    }
  },
  async run({ steps, $ }) {
    const s3 = new AWS.S3({
      apiVersion: "2006-03-01",
      signatureVersion: "v4",
      accessKeyId: process.env.AWS_ACCESS_KEY_ID,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
    });

    return new Promise((resolve, reject) => {
      s3.createPresignedPost({ Bucket: this.Bucket, Fields: { key: this.Key }, ...this.options }, (err, data) => {
        if (err) {
          reject(err);
        }

        resolve(data);
      });
    });


  },
})