Skip to content

Commit 1152ecd

Browse files
chore: add test to client close
Co-authored-by: TomasRup <tomasr@wix.com>
1 parent 7de20a0 commit 1152ecd

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/integration-tests/process-cleanup.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { StdioServerTransport } from '../server/stdio.js';
44
describe('Process cleanup', () => {
55
vi.setConfig({ testTimeout: 5000 }); // 5 second timeout
66

7-
it('should exit cleanly after closing transport', async () => {
7+
it('server should exit cleanly after closing transport', async () => {
88
const server = new Server(
99
{
1010
name: 'test-server',
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { setTimeout } from 'node:timers'
2+
import process from 'node:process'
3+
import { McpServer } from "../../dist/esm/server/mcp.js";
4+
import { StdioServerTransport } from "../../dist/esm/server/stdio.js";
5+
6+
const transport = new StdioServerTransport();
7+
8+
const server = new McpServer({
9+
name: "server-that-hangs",
10+
version: "1.0.0"
11+
});
12+
13+
await server.connect(transport);
14+
15+
const doNotExitImmediately = async () => {
16+
setTimeout(() => process.exit(0), 30 * 1000);
17+
};
18+
19+
process.stdin.on('close', doNotExitImmediately);
20+
process.on('SIGINT', doNotExitImmediately);
21+
process.on('SIGTERM', doNotExitImmediately);

0 commit comments

Comments
 (0)