Why am I Getting "$.respond() not called for this Invocation" Error in My Workflow When Using Pipedream with Postman?

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

I have this workflow but get “$.respond() not called for this invocation” as error:

  1. Trigger
    a. Setting: “Return a custom response from your workflow”
  2. Delay on 10 seconds
  3. Reponse:
    a. status: 200
    b. headers{0}body:hello world!
    Works fine in testing but postman get an error. I want pipedream to force to wait for the reponse.

Can anyone help?

Hi , how do you do the delay on your workflow?

just the step = should I code it?

, there’s a helper function that you can use (as the image below). Just search for “Helper Function” and then search for Delay.

That is what I use

But fails with the reponse

, is it possible for you to record the behavior?

I tried to reproduce your behavior with the workflow but I see it executed correctly

Since the delay step suspends the execution of your workflow, you can’t delay and then return an HTTP response synchronously. @U05A7KLNALC can you rewrite the delay step above by awaiting a Promise on a setTimeout for 10 seconds?

Sure, you can use a Promise with a setTimeout to create a delay in your code. Here’s how you can do it: export default { name: "delayedResponse", type: "http", version: "0.0.1", props: { http: "$.interface.http", }, async run({ $ }) { // Create a new promise that resolves after a 10 second delay await new Promise((resolve) => setTimeout(resolve, 10000)); // Send the HTTP response this.http.respond({ status: 200, headers: { "Content-Type": "text/plain", }, body: "Hello, world!", }); }, }; This code creates a new Promise that resolves after a 10 second delay. The await keyword causes the function to pause and wait for the Promise to resolve before continuing. After the delay, the function sends the HTTP response.

Posted thread to Discourse: Why am I Getting "$.respond() not called for this invocation" Error in Pipedream Workflow When Using Postman?

I have a hard time get this to work. The flow is not delayed but it stops instead

After this code I run everything else (but it never comes to it)

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    slack: {
      type: "app",
      app: "slack",
    },
  },
  async run({ steps, $ }) {
    // Set the delay for 48 hours (48 hours ** 60 minutes ** 60 seconds ** 1000 milliseconds)
    const { cancel_url } = $.flow.delay(60**1000);

    // Send a message to Slack with the cancel URL
    await axios($, {
      url: "https://slack.com/api/chat.postMessage",
      method: "POST",
      headers: {
        Authorization: `Bearer ${this.slack.$auth.oauth_access_token}`,
      },
      data: {
        channel: "************************", // Slack user or channel ID
        text: `Cancel URL: ${cancel_url}`, // Message content
      },
    });

    // ... run any code you want here
  },
});

Hi , the problem is that when you send the Cancel URL within a Slack message, Slack will automatically request to that Cancel URL for rendering link preview. So you might need to disable link preview on Slack, or saving the link preview to somewhere that does not request to the Cancel URL immediately.

My example below storing the Cancel URL in a Pipedream Data store, and the workflow delay correctly