@@ -15,7 +15,6 @@ import { Heart } from "../heart"
15
15
import { ensureAuthenticated , redirect } from "../http"
16
16
import { PluginAPI } from "../plugin"
17
17
import { getMediaMime , paths } from "../util"
18
- import { wrapper } from "../wrapper"
19
18
import * as apps from "./apps"
20
19
import * as domainProxy from "./domainProxy"
21
20
import { errorHandler , wsErrorHandler } from "./errors"
@@ -46,9 +45,6 @@ export const register = async (
46
45
} )
47
46
} )
48
47
} )
49
- server . on ( "close" , ( ) => {
50
- heart . dispose ( )
51
- } )
52
48
53
49
app . disable ( "x-powered-by" )
54
50
wsApp . disable ( "x-powered-by" )
@@ -114,13 +110,13 @@ export const register = async (
114
110
} )
115
111
} )
116
112
113
+ let pluginApi : PluginAPI
117
114
if ( ! process . env . CS_DISABLE_PLUGINS ) {
118
115
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 )
120
117
await pluginApi . loadPlugins ( )
121
118
pluginApi . mount ( app , wsApp )
122
119
app . use ( "/api/applications" , ensureAuthenticated , apps . router ( pluginApi ) )
123
- wrapper . onDispose ( ( ) => pluginApi . dispose ( ) )
124
120
}
125
121
126
122
app . use ( express . json ( ) )
@@ -170,6 +166,8 @@ export const register = async (
170
166
wsApp . use ( wsErrorHandler )
171
167
172
168
return ( ) => {
169
+ heart . dispose ( )
170
+ pluginApi ?. dispose ( )
173
171
vscode ?. codeServerMain . dispose ( )
174
172
}
175
173
}
0 commit comments