@@ -15,7 +15,6 @@ import { Heart } from "../heart"
1515import { ensureAuthenticated , redirect } from "../http"
1616import { PluginAPI } from "../plugin"
1717import { getMediaMime , paths } from "../util"
18- import { wrapper } from "../wrapper"
1918import * as apps from "./apps"
2019import * as domainProxy from "./domainProxy"
2120import { errorHandler , wsErrorHandler } from "./errors"
@@ -46,9 +45,6 @@ export const register = async (
4645 } )
4746 } )
4847 } )
49- server . on ( "close" , ( ) => {
50- heart . dispose ( )
51- } )
5248
5349 app . disable ( "x-powered-by" )
5450 wsApp . disable ( "x-powered-by" )
@@ -114,13 +110,13 @@ export const register = async (
114110 } )
115111 } )
116112
113+ let pluginApi : PluginAPI
117114 if ( ! process . env . CS_DISABLE_PLUGINS ) {
118115 const workingDir = args . _ && args . _ . length > 0 ? path . resolve ( args . _ [ args . _ . length - 1 ] ) : undefined
119- const pluginApi = new PluginAPI ( logger , process . env . CS_PLUGIN , process . env . CS_PLUGIN_PATH , workingDir )
116+ pluginApi = new PluginAPI ( logger , process . env . CS_PLUGIN , process . env . CS_PLUGIN_PATH , workingDir )
120117 await pluginApi . loadPlugins ( )
121118 pluginApi . mount ( app , wsApp )
122119 app . use ( "/api/applications" , ensureAuthenticated , apps . router ( pluginApi ) )
123- wrapper . onDispose ( ( ) => pluginApi . dispose ( ) )
124120 }
125121
126122 app . use ( express . json ( ) )
@@ -170,6 +166,8 @@ export const register = async (
170166 wsApp . use ( wsErrorHandler )
171167
172168 return ( ) => {
169+ heart . dispose ( )
170+ pluginApi ?. dispose ( )
173171 vscode ?. codeServerMain . dispose ( )
174172 }
175173}
0 commit comments