Skip to content

Commit b077d94

Browse files
authored
chore: update some logs on extension host process service (#2173)
* chore: update manifest.json * fix: auto kill extension host process when disconnected * chore: update extension host log message * chore: update some logs
1 parent 061ff4c commit b077d94

14 files changed

Lines changed: 849 additions & 852 deletions

File tree

packages/connection/src/node/common-channel-handler.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,18 @@ export class CommonChannelHandler extends WebSocketHandler {
121121

122122
// 心跳消息
123123
if (msgObj.kind === 'heartbeat') {
124-
// console.log(`heartbeat msg ${msgObj.clientId}`)
125124
connection.send(stringify(`heartbeat ${msgObj.clientId}`));
126125
} else if (msgObj.kind === 'client') {
127126
const clientId = msgObj.clientId;
128-
this.logger.log('new connection clientId', clientId);
127+
this.logger.log(`New connection with id ${clientId}`);
129128
connectionId = clientId;
130129
this.connectionMap.set(clientId, connection);
131130
this.hearbeat(connectionId, connection);
132131
// channel 消息处理
133132
} else if (msgObj.kind === 'open') {
134133
const channelId = msgObj.id; // CommonChannelHandler.channelId ++;
135134
const { path } = msgObj;
136-
this.logger.log('new open channelId', channelId, 'channelPath', path);
135+
this.logger.log(`Open a new connection channel ${channelId} with path ${path}`);
137136

138137
// 生成 channel 对象
139138
const connectionSend = this.channelConnectionSend(connection);
@@ -162,14 +161,12 @@ export class CommonChannelHandler extends WebSocketHandler {
162161

163162
channel.ready();
164163
} else {
165-
// console.log('connection message', msgObj.id, msgObj.kind, this.channelMap.get(msgObj.id));
166-
167164
const { id } = msgObj;
168165
const channel = this.channelMap.get(id);
169166
if (channel) {
170167
channel.handleMessage(msgObj);
171168
} else {
172-
this.logger.warn(`channel ${id} not found`);
169+
this.logger.warn(`The channel(${id}) was not found`);
173170
}
174171
}
175172
} catch (e) {
@@ -184,15 +181,15 @@ export class CommonChannelHandler extends WebSocketHandler {
184181
clearTimeout(this.heartbeatMap.get(connectionId) as NodeJS.Timeout);
185182
this.heartbeatMap.delete(connectionId);
186183

187-
this.logger.verbose(`clear heartbeat ${connectionId}`);
184+
this.logger.verbose(`Clear heartbeat from channel ${connectionId}`);
188185
}
189186

190187
Array.from(this.channelMap.values())
191188
.filter((channel) => channel.id.toString().indexOf(connectionId) !== -1)
192189
.forEach((channel) => {
193190
channel.close(1, 'close');
194191
this.channelMap.delete(channel.id);
195-
this.logger.verbose(`remove channel ${channel.id}`);
192+
this.logger.verbose(`Remove connection channel ${channel.id}`);
196193
});
197194
});
198195
});

packages/core-node/src/connection.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function createServerConnection2(
3737
// 事件由 connection 的时机来触发
3838
commonChannelPathHandler.register('RPCService', {
3939
handler: (connection: WSChannel, clientId: string) => {
40-
logger.log(`set rpc connection ${clientId}`);
40+
logger.log(`New RPC connection ${clientId}`);
4141

4242
const serviceCenter = new RPCServiceCenter(undefined, logger);
4343
const serviceChildInjector = bindModuleBackService(injector, modulesInstances, serviceCenter, clientId);
@@ -50,10 +50,10 @@ export function createServerConnection2(
5050
serviceCenter.removeConnection(serverConnection);
5151
serviceChildInjector.disposeAll();
5252

53-
logger.log(`remove rpc connection ${clientId} `);
53+
logger.log(`Remove RPC connection ${clientId}`);
5454
});
5555
},
56-
dispose: (connection: ws, connectionClientId: string) => {},
56+
dispose: () => {},
5757
});
5858

5959
socketRoute.registerHandler(channelHandler);
@@ -76,15 +76,12 @@ export function createNetServerConnection(server: net.Server, injector, modulesI
7676
);
7777

7878
server.on('connection', (connection) => {
79-
logger.log('set net rpc connection');
8079
const serverConnection = createSocketConnection(connection);
8180
serviceCenter.setConnection(serverConnection);
8281

8382
connection.on('close', () => {
8483
serviceCenter.removeConnection(serverConnection);
8584
serviceChildInjector.disposeAll();
86-
87-
logger.log('remove net rpc connection');
8885
});
8986
});
9087

@@ -97,15 +94,13 @@ export function bindModuleBackService(
9794
serviceCenter: RPCServiceCenter,
9895
clientId?: string,
9996
) {
100-
const logger = injector.get(INodeLogger);
10197
const { createRPCService } = initRPCService(serviceCenter);
10298

10399
const childInjector = injector.createChild();
104100
for (const module of modules) {
105101
if (module.backServices) {
106102
for (const service of module.backServices) {
107103
if (service.token) {
108-
logger.log('back service', service.token);
109104
const serviceToken = service.token;
110105

111106
if (!injector.creatorMap.has(serviceToken)) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from '@opensumi/ide-core-browser';
2121

2222
import {
23+
CONNECTION_HANDLE_BETWEEN_EXTENSION_AND_MAIN_THREAD,
2324
ExtensionNodeServiceServerPath,
2425
IExtension,
2526
IExtensionHostService,
@@ -172,7 +173,7 @@ export class NodeExtProcessService implements AbstractNodeExtProcessService<IExt
172173
mainThreadCenter.setConnection(createElectronClientConnection(connectPath));
173174
} else {
174175
const WSChannelHandler = this.injector.get(IWSChannelHandler);
175-
const channel = await WSChannelHandler.openChannel('ExtMainThreadConnection');
176+
const channel = await WSChannelHandler.openChannel(CONNECTION_HANDLE_BETWEEN_EXTENSION_AND_MAIN_THREAD);
176177
mainThreadCenter.setConnection(createWebSocketConnection(channel));
177178
}
178179

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const CONNECTION_HANDLE_BETWEEN_EXTENSION_AND_MAIN_THREAD = 'ExtMainThreadConnection';

0 commit comments

Comments
 (0)