Error: Cannot set headers after they are sent to the client

Wappler Version : 4.5.0
Operating System : MacOS
Server Model: NodeJS
Database Type: N/A
Hosting Type: Docker

Expected behavior

Correct error handling: API route throws error due to missing $_GET[‘hello’]

Actual behavior

Error handling fails and falls back to a generic route error “Cannot GET /test”

Web Server logs:

server-connect:server Got error? Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
  server-connect:server     at new NodeError (node:internal/errors:371:5)
  server-connect:server     at ServerResponse.setHeader (node:_http_outgoing:576:11)
  server-connect:server     at ServerResponse.header (/opt/node_app/node_modules/express/lib/response.js:776:10)
  server-connect:server     at ServerResponse.send (/opt/node_app/node_modules/express/lib/response.js:170:12)
  server-connect:server     at ServerResponse.json (/opt/node_app/node_modules/express/lib/response.js:267:15)
  server-connect:server     at /opt/node_app/lib/server.js:57:29
  server-connect:server     at Layer.handle [as handle_request] (/opt/node_app/node_modules/express/lib/router/layer.js:95:5)
  server-connect:server     at trim_prefix (/opt/node_app/node_modules/express/lib/router/index.js:323:13)
  server-connect:server     at /opt/node_app/node_modules/express/lib/router/index.js:284:7
  server-connect:server     at Function.process_params (/opt/node_app/node_modules/express/lib/router/index.js:341:12) {
  server-connect:server   code: 'ERR_HTTP_HEADERS_SENT'
  server-connect:server } +8s
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:371:5)
    at ServerResponse.setHeader (node:_http_outgoing:576:11)
    at ServerResponse.header (/opt/node_app/node_modules/express/lib/response.js:776:10)
    at ServerResponse.send (/opt/node_app/node_modules/express/lib/response.js:170:12)
    at ServerResponse.json (/opt/node_app/node_modules/express/lib/response.js:267:15)
    at /opt/node_app/lib/server.js:65:29
    at Layer.handle_error (/opt/node_app/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/opt/node_app/node_modules/express/lib/router/index.js:321:13)
    at /opt/node_app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/node_app/node_modules/express/lib/router/index.js:341:12)

How to reproduce

Create a new Server Action “test”, specify a required input $_GET (e.g.: $_GET[‘hello’]), and then open the server action in the browser (without the GET argument ?hello)

Community Page
Last updated: