fix: uncaught exception in case https certificate issues "key values mismatch"
Massimo Melina committed
May 26, 2024 at 07:19 UTC
7313288734d781a6ef53e87b151441a27b9a971e
1 file changed
+4
-3
src/listen.ts
+4
-3
@@ -122,9 +122,10 @@ const considerHttps = debounceAsync(async () => {
122
return httpsSrv.error = "cannot read " + namesForOutput[cantRead]
123
}
124
}
125
- catch(e) {
126
- httpsSrv!.error = "bad private key or certificate"
127
- console.log("failed to create https server: check your private key and certificate", String(e))
125
+ catch(e: any) {
126
+ httpsSrv ||= Object.assign(https.createServer({}), { name: 'https' }) // a dummy container, in case creation failed because of certificate errors
127
+ httpsSrv.error = "bad private key or certificate"
128
+ console.error("failed to create https server: check your private key and certificate", e.message)
129
return
130
}
131
port = await startServer(httpsSrv, { port, host: listenInterface.get() })