revert
This commit is contained in:
parent
14df563c7d
commit
d1f7f22068
|
|
@ -1,13 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: MomentQYC and other misskey contributors
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
|
||||||
|
|
||||||
export async function ErrorHandler(error: Error, request: FastifyRequest, reply: FastifyReply): Promise<void> {
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
error.stack = undefined;
|
|
||||||
}
|
|
||||||
reply.send(error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
@ -12,9 +12,5 @@ export class FastifyReplyError extends Error {
|
||||||
super(message);
|
super(message);
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.statusCode = statusCode;
|
this.statusCode = statusCode;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
Object.defineProperty(this, 'stack', { value: undefined });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { ErrorHandler } from '@/misc/error.js';
|
|
||||||
import { ActivityPubServerService } from './ActivityPubServerService.js';
|
import { ActivityPubServerService } from './ActivityPubServerService.js';
|
||||||
import { NodeinfoServerService } from './NodeinfoServerService.js';
|
import { NodeinfoServerService } from './NodeinfoServerService.js';
|
||||||
import { ApiServerService } from './api/ApiServerService.js';
|
import { ApiServerService } from './api/ApiServerService.js';
|
||||||
|
|
@ -77,7 +76,6 @@ export class ServerService implements OnApplicationShutdown {
|
||||||
logger: !['production', 'test'].includes(process.env.NODE_ENV ?? ''),
|
logger: !['production', 'test'].includes(process.env.NODE_ENV ?? ''),
|
||||||
});
|
});
|
||||||
this.#fastify = fastify;
|
this.#fastify = fastify;
|
||||||
fastify.setErrorHandler(ErrorHandler);
|
|
||||||
|
|
||||||
// HSTS
|
// HSTS
|
||||||
// 6months (15552000sec)
|
// 6months (15552000sec)
|
||||||
|
|
|
||||||
|
|
@ -682,13 +682,12 @@ export class ClientServerService {
|
||||||
|
|
||||||
fastify.setErrorHandler(async (error, request, reply) => {
|
fastify.setErrorHandler(async (error, request, reply) => {
|
||||||
const errId = randomUUID();
|
const errId = randomUUID();
|
||||||
const stack = (process.env.NODE_ENV === 'production') ? '' : error.stack;
|
|
||||||
this.clientLoggerService.logger.error(`Internal error occurred in ${request.routerPath}: ${error.message}`, {
|
this.clientLoggerService.logger.error(`Internal error occurred in ${request.routerPath}: ${error.message}`, {
|
||||||
path: request.routerPath,
|
path: request.routerPath,
|
||||||
params: request.params,
|
params: request.params,
|
||||||
query: request.query,
|
query: request.query,
|
||||||
code: error.name,
|
code: error.name,
|
||||||
stack,
|
stack: error.stack,
|
||||||
id: errId,
|
id: errId,
|
||||||
});
|
});
|
||||||
reply.code(500);
|
reply.code(500);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue