Skip to content

Commit

Permalink
Remove tor initialized emit I added and add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
islathehut committed Apr 8, 2024
1 parent 9b0be80 commit e1fd059
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/backend/src/nest/storage/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,19 @@ export class StorageService extends EventEmitter {
const community = await this.localDbService.getCurrentCommunity()

if (community) {
this.logger(`Emitting ${StorageEvents.MESSAGE_IDS_STORED} storage event because community exists in local DB`)
this.emit(StorageEvents.MESSAGE_IDS_STORED, {
ids,
channelId: channelData.id,
communityId: community.id,
})
} else {
this.logger(`No community found in local DB`)
}
})

db.events.on('ready', async () => {
this.logger('Local DB ready.')
const ids = this.getAllEventLogEntries<ChannelMessage>(db).map(msg => msg.id)
const community = await this.localDbService.getCurrentCommunity()

Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/nest/tor/tor-control.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class TorControl {
this.logger(`Connecting to Tor, host: ${this.torControlParams.host} port: ${this.torControlParams.port}`)
await this._connect()
this.logger('Tor connected')
this.serverIoProvider.io.emit(SocketActionTypes.TOR_INITIALIZED)
return
} catch (e) {
this.logger(e)
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/nest/websocketOverTor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class WebSockets extends EventEmitter {
let maConn: MultiaddrConnection

try {
log('Dialling - ', ma.nodeAddress())
socket = await this._connect(ma, {
websocket: {
...this._websocketOpts,
Expand Down
15 changes: 11 additions & 4 deletions packages/desktop/src/renderer/sagas/socket/socket.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ function subscribeSocketLifecycle(socket?: Socket) {
logger.info('websocket connected')
emit(socketActions.setConnected())
})
socket?.on('disconnect', () => {
logger.info('closing socket connection')
emit(socketActions.suspendConnection())
})
socket?.on(
'disconnect',
async (reason: string, description?: Error | { description: string; context?: any } | undefined) => {
if (reason === 'transport error') {
logger.error(`Error occurred, closing connection with reason ${reason}`, description)
} else {
logger.info('closing socket connection', reason, description)
}
emit(socketActions.suspendConnection())
}
)
return () => {}
})
}
Expand Down

0 comments on commit e1fd059

Please sign in to comment.