From a0b7cac3a51547c1fd6016f11d83e661dbf50b03 Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:47:53 +0200 Subject: [PATCH] chore(core): Log failed webhook requests with debug (no-changelog) (#12599) --- .../cli/src/webhooks/webhook-request-handler.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/webhooks/webhook-request-handler.ts b/packages/cli/src/webhooks/webhook-request-handler.ts index 96cf6da745..8eb62358b1 100644 --- a/packages/cli/src/webhooks/webhook-request-handler.ts +++ b/packages/cli/src/webhooks/webhook-request-handler.ts @@ -1,5 +1,7 @@ +import { Container } from '@n8n/di'; import type express from 'express'; -import type { IHttpRequestMethods } from 'n8n-workflow'; +import { Logger } from 'n8n-core'; +import { ensureError, type IHttpRequestMethods } from 'n8n-workflow'; import * as ResponseHelper from '@/response-helper'; import type { @@ -52,8 +54,14 @@ class WebhookRequestHandler { response.headers, ); } - } catch (error) { - return ResponseHelper.sendErrorResponse(res, error as Error); + } catch (e) { + const error = ensureError(e); + Container.get(Logger).debug( + `Error in handling webhook request ${req.method} ${req.path}: ${error.message}`, + { stacktrace: error.stack }, + ); + + return ResponseHelper.sendErrorResponse(res, error); } }