Skip to content

Commit 335f393

Browse files
committed
feat(cli): ignore WS server already in use log
1 parent 4def464 commit 335f393

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/server/server.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class WebSocketServer {
7272
private mainProcessSocket: WebSocket | null = null;
7373
private gameProcessSocket: WebSocket | null = null;
7474
private gameListeners = new Map<GameClientMessageName, GameListener[]>();
75-
private gameSocketConnectionTimestamp: number | null = null;
7675

7776
constructor() {
7877
this.server = new WSServer({
@@ -153,7 +152,6 @@ class WebSocketServer {
153152
this.gameProcessSocket.on('close', this.onGameProcessSocketDisconnect);
154153
this.gameProcessSocket.on('error', this.onGameProcessSocketError);
155154
this.gameProcessSocket.on('message', this.onGameProcessSocketMessage);
156-
this.gameSocketConnectionTimestamp = Date.now();
157155
}
158156
};
159157

@@ -315,14 +313,18 @@ class WebSocketServer {
315313
this.gameProcessSocket = null;
316314

317315
this.gameListeners.clear();
318-
this.gameSocketConnectionTimestamp = null;
319316
};
320317

321318
private onGameProcessSocketError(error: unknown) {
322319
logger.error('WS:: game process socket error', error);
323320
}
324321

325322
private onError = (error: Error) => {
323+
// Ignore port already in use errors in CLI, it means the GUI is running and so the WS server too.
324+
if (process.env.PROCESS_NAME === 'cli' && 'code' in error && error.code === 'EADDRINUSE') {
325+
return;
326+
}
327+
326328
logger.error('WS:: an error occurred');
327329
logger.error(error);
328330
};

0 commit comments

Comments
 (0)