Skip to content

Commit 642e080

Browse files
authored
fix: clear old listen and initView when extension restart (#2530)
1 parent 9a55805 commit 642e080

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/extension/src/browser/extension.service.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
364364
if (!init) {
365365
// 重启场景下需要将申明过 browserView 的 sumi 插件的 contributes 重新跑一遍
366366
await this.rerunSumiViewExtensionContributes();
367-
368367
// 重启场景下把 ActivationEvent 再发一次
369368
if (this.activationEventService.activatedEventSet.size) {
370369
const activatedEventArr = Array.from(this.activationEventService.activatedEventSet);
@@ -630,9 +629,19 @@ export class ExtensionServiceImpl extends WithEventBus implements ExtensionServi
630629
const extensionPaths = Array.from(activatedViewExtensionMap.keys());
631630

632631
await Promise.all(
633-
extensionPaths.map((path) => this.extensionInstanceManageService.getExtensionInstanceByPath(path)?.initialize()),
632+
extensionPaths.map((path) => {
633+
const extension = this.extensionInstanceManageService.getExtensionInstanceByPath(path);
634+
if (extension) {
635+
extension.initialize();
636+
this.contributesService.register(extension.id, extension.contributes);
637+
this.sumiContributesService.register(extension.id, extension.packageJSON.kaitianContributes || {});
638+
}
639+
}),
634640
);
635641

642+
this.contributesService.initialize();
643+
this.sumiContributesService.initialize();
644+
636645
activatedViewExtensionMap.clear();
637646
}
638647

packages/extension/src/node/extension.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ export class ExtensionNodeServiceImpl implements IExtensionNodeService {
256256
extServer.listen(extServerListenOptions, () => {
257257
this.logger.log(`${clientId} ext server listen on ${JSON.stringify(extServerListenOptions)}`);
258258
});
259+
// 重启时,旧的 path 已经不再使用,但是系统未清理,导致 listen 会失败,所以在连接关闭时,主动清理
260+
extServer.on('close', () => {
261+
this.extServerListenOptions.delete(clientId);
262+
});
259263
}
260264

261265
private async _createExtHostProcess(clientId: string, options?: ICreateProcessOptions) {

0 commit comments

Comments
 (0)