Skip to content

Commit 7100a43

Browse files
committed
refactor: Remove non-null assertion for server reject handler
1 parent 41177b0 commit 7100a43

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/lib/server.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ export async function startServer(repoPath: string): Promise<void> {
460460

461461
const activeSessionTransports: Map<string, StreamableHTTPServerTransport> = new Map();
462462

463-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
463+
464464
expressApp.post('/mcp', async (req: express.Request, res: express.Response) => {
465465
const sessionId = req.headers['mcp-session-id'] as string | undefined;
466466
let transport: StreamableHTTPServerTransport | undefined = sessionId ? activeSessionTransports.get(sessionId) : undefined;
@@ -527,9 +527,9 @@ export async function startServer(repoPath: string): Promise<void> {
527527
}
528528
}
529529
};
530-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
530+
531531
expressApp.get('/mcp', handleSessionRequest);
532-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
532+
533533
expressApp.delete('/mcp', handleSessionRequest);
534534
logger.info(`MCP communication will be available at the /mcp endpoint via POST, GET, DELETE.`);
535535

@@ -566,10 +566,10 @@ export async function startServer(repoPath: string): Promise<void> {
566566
console.info(`Last Updated: ${existingStatus.lastUpdatedAt}`);
567567
console.info(`-----------------------------------------------------------\n`);
568568
logger.info("Current instance will exit as another CodeCompass server is already running.");
569-
httpServerSetupReject!(new ServerStartupError(`Port ${httpPort} in use by another CodeCompass instance.`, 0));
569+
httpServerSetupReject(new ServerStartupError(`Port ${httpPort} in use by another CodeCompass instance.`, 0));
570570
} else {
571571
logger.error(`Failed to retrieve status from existing CodeCompass server on port ${httpPort}. It responded to ping but status endpoint failed. Status: ${statusResponse.status}`);
572-
httpServerSetupReject!(new ServerStartupError(`Port ${httpPort} in use, status fetch failed.`, 1));
572+
httpServerSetupReject(new ServerStartupError(`Port ${httpPort} in use, status fetch failed.`, 1));
573573
}
574574
} catch (statusError: unknown) {
575575
if (axios.isAxiosError(statusError)) {
@@ -583,12 +583,12 @@ export async function startServer(repoPath: string): Promise<void> {
583583
} else {
584584
logger.error(`Error fetching status from existing CodeCompass server (port ${httpPort}): ${String(statusError)}`);
585585
}
586-
httpServerSetupReject!(new ServerStartupError(`Port ${httpPort} in use, status fetch error.`, 1));
586+
httpServerSetupReject(new ServerStartupError(`Port ${httpPort} in use, status fetch error.`, 1));
587587
}
588588
} else {
589589
logger.error(`Port ${httpPort} is in use by non-CodeCompass server. Response: ${JSON.stringify(pingResponse.data)}`);
590590
logger.error(`Please free the port or configure a different one (e.g., via HTTP_PORT environment variable or in ~/.codecompass/model-config.json).`);
591-
httpServerSetupReject!(new ServerStartupError(`Port ${httpPort} in use by non-CodeCompass server.`, 1));
591+
httpServerSetupReject(new ServerStartupError(`Port ${httpPort} in use by non-CodeCompass server.`, 1));
592592
}
593593
} catch (pingError) {
594594
logger.error(`Port ${httpPort} is in use by an unknown service or the existing CodeCompass server is unresponsive to pings.`);
@@ -604,11 +604,11 @@ export async function startServer(repoPath: string): Promise<void> {
604604
logger.error(`Ping error details: ${String(pingError)}`);
605605
}
606606
logger.error(`Please free the port or configure a different one (e.g., via HTTP_PORT environment variable or in ~/.codecompass/model-config.json).`);
607-
httpServerSetupReject!(new ServerStartupError(`Port ${httpPort} in use or ping failed.`, 1));
607+
httpServerSetupReject(new ServerStartupError(`Port ${httpPort} in use or ping failed.`, 1));
608608
}
609609
} else {
610610
logger.error(`Failed to start HTTP server on port ${httpPort}: ${error.message}`);
611-
httpServerSetupReject!(new ServerStartupError(`HTTP server error: ${error.message}`, 1));
611+
httpServerSetupReject(new ServerStartupError(`HTTP server error: ${error.message}`, 1));
612612
}
613613
});
614614

0 commit comments

Comments
 (0)