fix: 修复长上下文请求超时问题

- 设置HTTP服务器超时时间与代理超时时间一致
- 默认超时时间为5分钟(可通过DEFAULT_PROXY_TIMEOUT环境变量配置)
- 同时设置keepAliveTimeout避免连接过早断开
- 解决了Node.js默认2分钟超时导致的长上下文处理中断问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
shaw
2025-07-18 14:04:51 +08:00
parent 4372b29252
commit 6988be0806

View File

@@ -270,6 +270,13 @@ class Application {
logger.info(`📊 Metrics: http://${config.server.host}:${config.server.port}/metrics`);
});
// 设置服务器超时时间,与代理超时时间一致
const serverTimeout = config.proxy.timeout || 300000; // 默认5分钟
this.server.timeout = serverTimeout;
this.server.keepAliveTimeout = serverTimeout + 5000; // keepAlive 稍长一点
logger.info(`⏱️ Server timeout set to ${serverTimeout}ms (${serverTimeout/1000}s)`);
// 🔄 定期清理任务
this.startCleanupTasks();