fix: ERR_HTTP_REQUEST_TIMEOUT on https

Massimo Melina committed Sep 17, 2023 at 18:04 UTC b6e2e15c7e66cb279763e7934741f7b273d2c276
1 file changed +4 -2
src/listen.ts
+4 -2
@@ -26,12 +26,14 @@ export function getHttpsWorkingPort() {
26 return httpsSrv?.listening && (httpsSrv.address() as any)?.port
27 }
28
29 +const commonOptions = { requestTimeout: 0 }
30 +
31 export const portCfg = defineConfig<number>('port', 80)
32 portCfg.sub(async port => {
33 while (!app)
34 await wait(100)
35 stopServer(httpSrv).then()
34 - httpSrv = Object.assign(http.createServer({ requestTimeout: 0 }, app.callback()), { name: 'http' })
36 + httpSrv = Object.assign(http.createServer(commonOptions, app.callback()), { name: 'http' })
37 port = await startServer(httpSrv, { port })
38 if (!port) return
39 httpSrv.on('connection', newConnection)
@@ -70,7 +72,7 @@ const considerHttps = debounceAsync(async () => {
72 while (!app)
73 await wait(100)
74 httpsSrv = Object.assign(
73 - https.createServer(port === PORT_DISABLED ? {} : { key: httpsOptions.private_key, cert: httpsOptions.cert }, app.callback()),
75 + https.createServer(port === PORT_DISABLED ? {} : { ...commonOptions, key: httpsOptions.private_key, cert: httpsOptions.cert }, app.callback()),
76 { name: 'https' }
77 )
78 if (port >= 0) {