I encountered a problem. I want to customize a webhook node and a response node.
I defined the following webhook node:
{
webhooks: [
{
name: 'default',
httpMethod: 'POST',
path: 'wechat',
responseMode: 'responseNode',
}
],
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
return {
workflowData: [this.helpers.returnJsonArray(data)],
};
}
}
When I call this.sendResponse(response) in the response node, an error is reported
Error: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (node:_http_outgoing:655:11)
at ServerResponse.header (/usr/local/lib/node_modules/n8n/node_modules/express/lib/response.js:794:10)
at ServerResponse.json (/usr/local/lib/node_modules/n8n/node_modules/express/lib/response.js:275:10)
at Object.sendErrorResponse (/usr/local/lib/node_modules/n8n/dist/response-helper.js:98:32)
at WebhookRequestHandler.handleRequest (/usr/local/lib/node_modules/n8n/dist/webhooks/webhook-request-handler.js:69:35)
at /usr/local/lib/node_modules/n8n/dist/webhooks/webhook-request-handler.js:120:9
Then I tried to add noWebhookResponse: true in the webhook node
But the request was blocked and kept waiting for the response.