From a0985cfd369f7f841e54a0bc2b14f71a99107080 Mon Sep 17 00:00:00 2001 From: Zeck Li <11781254+zeckli@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:14:28 +0800 Subject: [PATCH] fix(timeout): avoid connection reset --- src/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 46885fad6..1fcc348aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -91,8 +91,12 @@ const { version } = require('../package.json') // Sentry error handler Sentry.setupExpressErrorHandler(app) - await new Promise((resolve) => - app.listen({ port: PORT }, resolve as () => void) - ) - console.log(`🚀 Server ready at http://localhost:${PORT}/graphql`) + const httpServer = app.listen({ port: PORT }, () => { + console.log(`🚀 Server ready at http://localhost:${PORT}/graphql`) + }) + + // Keep server keep-alive longer than nginx upstream to avoid reusing + // connections the server already closed (connection reset by peer). + httpServer.keepAliveTimeout = 65000 + httpServer.headersTimeout = 66000 })()