From d3d201d0cf40cc75aad1a55f54375353f571e129 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Sun, 25 May 2025 14:57:02 -0400 Subject: [PATCH] reduce log spam from ApiCallService --- .../backend/src/server/api/ApiCallService.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 7015e1cd69..6d6c86bb82 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -27,6 +27,7 @@ import { AuthenticateService, AuthenticationError } from './AuthenticateService. import type { FastifyRequest, FastifyReply } from 'fastify'; import type { OnApplicationShutdown } from '@nestjs/common'; import type { IEndpointMeta, IEndpoint } from './endpoints.js'; +import { renderFullError } from '@/misc/render-full-error.js'; const accessDenied = { message: 'Access denied.', @@ -101,15 +102,16 @@ export class ApiCallService implements OnApplicationShutdown { throw err; } else { const errId = randomUUID(); - this.logger.error(`Internal error occurred in ${ep.name}: ${renderInlineError(err)}`, { - ep: ep.name, + const fullError = renderFullError(err); + const message = typeof(fullError) === 'string' + ? `Internal error id=${errId} occurred in ${ep.name}: ${fullError}` + : `Internal error id=${errId} occurred in ${ep.name}:`; + const data = typeof(fullError) === 'object' + ? { e: fullError } + : {}; + this.logger.error(message, { user: userId ?? '', - e: { - message: err.message, - code: err.name, - stack: err.stack, - id: errId, - }, + ...data, }); if (this.config.sentryForBackend) {