API Action - Cannot set headers after they are sent to the client

Wappler Version : 4.2.2
Operating System : macOS Catalina (10.15.7)
Server Model: nodejs
Database Type: postgresql
Hosting Type: Own Server

Expected behavior

What do you think should happen?

I have an API action that calls an external endpoint. The call used to work successfully.

Actual behavior

What actually happens?

Now when the API action is called I get the error message “Cannot set headers after they are sent to the client”

How to reproduce

  • Detail a step by step guide to reproduce the issue
  • A screenshot or short video indicating the problem
  • A copy of your code would help. Include: JS, HTML.
  • Test your steps on a clean page to see if you still have an issue

The screenshot below shows how my API Action looks. Note: I did have a Security Restrict as the first step. However, searching in the forum for this issue it was suggested to remove the restrict step to see if this fixed it. However, as you can see by the screenshot below the problem still exists even without the restrict step.

Couold be related to: Nodejs server crash (ERR_HTTP_HEADERS_SENT)

It could be, although it says that issue was fixed in an earlier release.

Did the api call return an error? Try unchecking the Pass Errors and check the result then.

I unchecked Pass Errors and it didn’t show anything. The reason for this is that the end point I was calling was failing but was returning 200 with the error code in the response body.

Everything’s all fixed up now so feel free to close this issue, and thanks for the help.