File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { StdioServerTransport } from '../server/stdio.js';
44describe ( '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' ,
Original file line number Diff line number Diff line change 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 ) ;
You can’t perform that action at this time.
0 commit comments