File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ const runServer = async (options: ServerOptions = getOptions(), {
129129 let transport : StdioServerTransport | null = null ;
130130 let httpHandle : HttpServerHandle | null = null ;
131131 let unsubscribeServerLogger : ( ( ) => void ) | null = null ;
132+ let sigintHandler : ( ( ) => void ) | null = null ;
132133 let running = false ;
133134 let onLogSetup : ServerOnLog = ( ) => ( ) => { } ;
134135
@@ -144,6 +145,11 @@ const runServer = async (options: ServerOptions = getOptions(), {
144145 httpHandle = null ;
145146 }
146147
148+ if ( sigintHandler ) {
149+ process . off ( 'SIGINT' , sigintHandler ) ;
150+ sigintHandler = null ;
151+ }
152+
147153 log . debug ( '...closing Server' ) ;
148154 await server ?. close ( ) ;
149155 running = false ;
@@ -246,10 +252,11 @@ const runServer = async (options: ServerOptions = getOptions(), {
246252 } ) ) ) ;
247253 } ) ;
248254
249- if ( enableSigint ) {
250- process . on ( 'SIGINT' , ( ) => {
255+ if ( enableSigint && ! sigintHandler ) {
256+ sigintHandler = ( ) => {
251257 void stopServer ( ) ;
252- } ) ;
258+ } ;
259+ process . on ( 'SIGINT' , sigintHandler ) ;
253260 }
254261
255262 if ( options . isHttp ) {
You can’t perform that action at this time.
0 commit comments