Why am I Getting "$.respond() not called for this invocation" Error in Pipedream Workflow When Using 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.