Fix: таймаут 10с на все запросы — не висим, не даём nginx 503. Версия 0.1.25
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user