Fix: таймаут 10с на все запросы — не висим, не даём nginx 503. Версия 0.1.25

This commit is contained in:
2026-07-09 10:36:17 +04:00
parent e5b536c3ce
commit bf24d1577f
3 changed files with 13 additions and 2 deletions
+11
View File
@@ -57,6 +57,17 @@ app.use(cookieParser());
async function start() {
const auth = await initAuth();
// ── Стоп-кран: если запрос висит > 10 сек — обрываем с ошибкой ───────
app.use((req, res, next) => {
const timer = setTimeout(() => {
if (!res.headersSent) {
res.status(503).type('html').send('<h2>Сервис временно недоступен</h2><p>Превышено время ожидания</p>');
}
}, 10000);
res.on('finish', () => clearTimeout(timer));
next();
});
// ── Сессии ────────────────────────────────────────────────────────────────
const { pool } = require('./src/db');
app.use(createSessionMiddleware(pool));