feat: 限制远程应用最大重连次数为 50,增强错误日志信息;调整 cnb-board 路由逻辑

This commit is contained in:
2026-02-24 23:53:21 +08:00
parent 37e00a9ff3
commit 22ef776b27
3 changed files with 4 additions and 4 deletions

View File

@@ -139,7 +139,7 @@ export class AssistantApp extends Manager {
// 使用 RemoteApp 内置的自动重连机制 // 使用 RemoteApp 内置的自动重连机制
autoReconnect: true, autoReconnect: true,
reconnectDelay: 5000, // 首次重连延迟 5 秒 reconnectDelay: 5000, // 首次重连延迟 5 秒
maxReconnectAttempts: Infinity, // 无限重连 maxReconnectAttempts: 50, // 最大重连次数
enableBackoff: true, // 启用指数退避 enableBackoff: true, // 启用指数退避
}); });
remoteApp.isConnect(); remoteApp.isConnect();
@@ -161,7 +161,7 @@ export class AssistantApp extends Manager {
logger.info('[remote-app] 远程连接已关闭,自动重连机制正在处理...'); logger.info('[remote-app] 远程连接已关闭,自动重连机制正在处理...');
}); });
remoteApp.on('maxReconnectAttemptsReached', () => { remoteApp.on('maxReconnectAttemptsReached', () => {
logger.error('远程应用重连达到最大次数,停止重连'); logger.error('[remote-app] 远程应用重连达到最大次数,停止重连');
}); });
this.remoteApp = remoteApp; this.remoteApp = remoteApp;
} else { } else {

View File

@@ -207,7 +207,7 @@ export class RemoteApp {
this.emitter.emit('message', data); this.emitter.emit('message', data);
} }
onError(error: any) { onError(error: any) {
console.error('远程应用错误:', this.id, error); console.error(`[remote-app] 远程应用错误: ${this.id}`, error);
this.isError = true; this.isError = true;
this.emitter.emit('error', error); this.emitter.emit('error', error);
} }

View File

@@ -25,8 +25,8 @@ app.route({
} }
}).define(async (ctx) => { }).define(async (ctx) => {
const more = ctx.query?.more ?? false const more = ctx.query?.more ?? false
const list = getLiveMdContent({ more: more });
if (notCNBCheck(ctx)) return; if (notCNBCheck(ctx)) return;
const list = getLiveMdContent({ more: more });
ctx.body = { ctx.body = {
title: '开发环境模式配置', title: '开发环境模式配置',
list, list,