Skip to content

Commit

Permalink
feat(data-service): expose close event VSCODE-536 (#5849)
Browse files Browse the repository at this point in the history
* feat(data-service): expose serverClosed event VSCODE-536

* fest: listen on client close

* refactor: bump log id

* refactor: without disconnect
  • Loading branch information
alenakhineika authored Jun 4, 2024
1 parent 9972824 commit c2aa785
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/data-service/src/data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export type ExplainExecuteOptions = ExecutionOptions & {
export interface DataServiceEventMap {
topologyDescriptionChanged: (evt: TopologyDescriptionChangedEvent) => void;
connectionInfoSecretsChanged: () => void;
close: () => void;
}

export type UpdatePreviewChange = {
Expand Down Expand Up @@ -1017,7 +1018,7 @@ class DataServiceImpl extends WithLogContext implements DataService {
}

once(...args: Parameters<DataService['on']>) {
this._emitter.on(...args);
this._emitter.once(...args);
return this;
}

Expand Down Expand Up @@ -2276,6 +2277,11 @@ class DataServiceImpl extends WithLogContext implements DataService {
});
});

client.on('close', () => {
this._logger.info(mongoLogId(1_001_000_315), 'Client is closed');
this._emitter.emit('close');
});

client.on('serverClosed', (evt: ServerClosedEvent) => {
this._logger.info(mongoLogId(1_001_000_020), 'Server closed', {
address: evt.address,
Expand Down

0 comments on commit c2aa785

Please sign in to comment.