diff --git a/server/env.ts b/server/env.ts index 7b6d9d350..a68a1154a 100644 --- a/server/env.ts +++ b/server/env.ts @@ -167,6 +167,15 @@ export class Environment { @IsOptional() public WEB_CONCURRENCY = this.toOptionalNumber(process.env.WEB_CONCURRENCY); + /** + * How long a request should be processed before giving up and returning an + * error response to the client, defaults to 10s + */ + @IsNumber() + @IsOptional() + public REQUEST_TIMEOUT = + this.toOptionalNumber(process.env.REQUEST_TIMEOUT) ?? 10 * 1000; + /** * Base64 encoded private key if Outline is to perform SSL termination. */ diff --git a/server/index.ts b/server/index.ts index 46fa67fa2..8bd0c0741 100644 --- a/server/index.ts +++ b/server/index.ts @@ -118,6 +118,8 @@ async function start(id: number, disconnect: () => void) { }); server.listen(normalizedPortFlag || env.PORT || "3000"); + server.setTimeout(env.REQUEST_TIMEOUT); + process.once("SIGTERM", shutdown); process.once("SIGINT", shutdown);