fix: do not emit unhandledreject event

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2022-09-04 15:11:33 +08:00
parent 932d505e4b
commit 88feacb4e5
4 changed files with 15 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ export class RedisIoAdapter extends IoAdapter {
const redisAdapter = createAdapter(pubClient, subClient, {
key: RedisIoAdapterKey,
requestsTimeout: 3000,
requestsTimeout: 10000,
})
server.adapter(redisAdapter)
return server

View File

@@ -52,13 +52,13 @@ export class AllExceptionsFilter implements ExceptionFilter {
process.on('unhandledRejection', (reason: any) => {
console.error('unhandledRejection: ', reason)
this.eventManager.broadcast(
EventBusEvents.SystemException,
{ message: reason?.message ?? reason, stack: reason?.stack || '' },
{
scope: EventScope.TO_SYSTEM,
},
)
// this.eventManager.broadcast(
// EventBusEvents.SystemException,
// { message: reason?.message ?? reason, stack: reason?.stack || '' },
// {
// scope: EventScope.TO_SYSTEM,
// },
// )
})
process.on('uncaughtException', (err) => {

View File

@@ -23,8 +23,9 @@ import { getShortDate } from '~/utils/time.util'
import { BoardcastBaseGateway } from '../base.gateway'
import { DanmakuDto } from './dtos/danmaku.dto'
const namespace = 'web'
@WebSocketGateway<GatewayMetadata>({
namespace: 'web',
namespace,
})
export class WebEventsGateway
extends BoardcastBaseGateway
@@ -60,7 +61,7 @@ export class WebEventsGateway
async getcurrentClientCount() {
const server = this.namespace.server
const sockets = await server.of('/web').adapter.sockets(new Set())
const sockets = await server.of(`/${namespace}`).adapter.sockets(new Set())
return sockets.size
}
async handleConnection(socket: SocketIO.Socket) {
@@ -100,6 +101,8 @@ export class WebEventsGateway
override broadcast(event: BusinessEvents, data: any) {
const emitter = this.cacheService.emitter
emitter.of('/web').emit('message', this.gatewayMessageFormat(event, data))
emitter
.of(`/${namespace}`)
.emit('message', this.gatewayMessageFormat(event, data))
}
}

View File

@@ -61,6 +61,7 @@ export class CacheService {
this._emitter = new Emitter(this.redisClient, {
key: RedisIoAdapterKey,
})
return this._emitter
}