From df8426d1029ab098b4041caaa25d5c0ad790eb9f Mon Sep 17 00:00:00 2001 From: QCQCQC <1220204124@zust.edu.cn> Date: Thu, 16 Oct 2025 11:18:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86require=20errors.j?= =?UTF-8?q?s=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/server/start.js | 8 +++++++- src/server/start.ts | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/server/start.js b/lib/server/start.js index 940c38b..51e772a 100644 --- a/lib/server/start.js +++ b/lib/server/start.js @@ -39,7 +39,13 @@ function concat(...paths) { }); } async function startup(path, connector, omitWatchers, omitTimers, routine) { - const errorHandler = require((0, path_1.join)(path, 'lib', 'configuration', 'errors')).default; + let errorHandler = undefined; + try { + errorHandler = require((0, path_1.join)(path, 'lib', 'configuration', 'errors')).default; + } + catch (err) { + // 不存在errors配置 + } const serverConfiguration = require((0, path_1.join)(path, 'lib', 'configuration', 'server')).default; // 拿到package.json,用作项目的唯一标识,否则无法区分不同项目的Redis+socketIO连接 const packageJson = require((0, path_1.join)(path, 'package.json')); diff --git a/src/server/start.ts b/src/server/start.ts index da2fbb7..80485f8 100644 --- a/src/server/start.ts +++ b/src/server/start.ts @@ -57,12 +57,18 @@ export async function startup) => Promise, ): Promise<(() => Promise) | any> { - const errorHandler: ErrorHandler = require(join( - path, - 'lib', - 'configuration', - 'errors' - )).default; + let errorHandler: ErrorHandler | undefined = undefined; + + try { + errorHandler = require(join( + path, + 'lib', + 'configuration', + 'errors' + )).default; + } catch (err) { + // 不存在errors配置 + } const serverConfiguration: ServerConfiguration = require(join( path, @@ -218,7 +224,7 @@ export async function startup { if (props.level === "error") { appLoader.execRoutine(async (ctx) => { - await errorHandler( props.caller, props.args, ctx); + await errorHandler(props.caller, props.args, ctx); }).catch((err) => { console.warn('执行全局错误处理失败:', err); }); From 97bc9b80427701a242ceb97f2cd4f893c3edf73e Mon Sep 17 00:00:00 2001 From: QCQCQC <1220204124@zust.edu.cn> Date: Thu, 16 Oct 2025 11:21:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E5=B7=B2=E5=BC=83=E7=94=A8=E7=9A=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/watch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/watch.ts b/src/server/watch.ts index d930ffb..abad55b 100644 --- a/src/server/watch.ts +++ b/src/server/watch.ts @@ -16,7 +16,7 @@ import { LogFormatter, LogFormatterProp, polyfillConsole } from "./polyfill"; 服务器重启 → 清理缓存并重新启动服务 */ -declare const require: NodeRequire; +declare const require: NodeJS.Require; declare const process: NodeJS.Process;