fix(gateway): close server in canBindToHost error handler

Ensure testServer.close() is called in both success and error paths
to prevent file descriptor leaks when bind fails.
This commit is contained in:
Episkey 2026-01-26 15:11:43 +08:00
parent 6859e1e6a6
commit d5c59c5174
2 changed files with 2 additions and 0 deletions

View File

@ -36,6 +36,7 @@ Status: unreleased.
### Fixes
- Web UI: improve WebChat image paste previews and allow image-only sends. (#1925) Thanks @smartprogrammer93.
- Gateway: fix server resource leak in canBindToHost error handler.
## 2026.1.24-3

View File

@ -140,6 +140,7 @@ export async function canBindToHost(host: string): Promise<boolean> {
return new Promise((resolve) => {
const testServer = net.createServer();
testServer.once("error", () => {
testServer.close();
resolve(false);
});
testServer.once("listening", () => {