Fix issue where WebSocketBus depends on Session before session factory registered
This commit is contained in:
parent
e339ec718d
commit
085fe04f90
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@extollo/lib",
|
||||
"version": "0.13.7",
|
||||
"version": "0.13.8",
|
||||
"description": "The framework library that lifts up your code.",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
@ -19,6 +19,7 @@ import {AsyncResource, executionAsyncId} from 'async_hooks'
|
||||
import {Session} from '../../http/session/Session'
|
||||
import {Config} from '../../service/Config'
|
||||
import {WebSocketHealthCheckEvent} from '../../http/lifecycle/WebSocketHealthCheckEvent'
|
||||
import {Request} from '../../http/lifecycle/Request'
|
||||
|
||||
@Injectable()
|
||||
export class WebSocketBus implements EventBus, AwareOfContainerLifecycle {
|
||||
@ -40,6 +41,9 @@ export class WebSocketBus implements EventBus, AwareOfContainerLifecycle {
|
||||
@Inject()
|
||||
protected readonly ws!: WebSocket.WebSocket
|
||||
|
||||
@Inject()
|
||||
protected readonly request!: Request
|
||||
|
||||
@Inject()
|
||||
protected readonly bus!: Bus
|
||||
|
||||
@ -49,9 +53,6 @@ export class WebSocketBus implements EventBus, AwareOfContainerLifecycle {
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
@Inject()
|
||||
protected readonly session!: Session
|
||||
|
||||
@Inject()
|
||||
protected readonly config!: Config
|
||||
|
||||
@ -118,15 +119,16 @@ export class WebSocketBus implements EventBus, AwareOfContainerLifecycle {
|
||||
|
||||
// If configured, re-load the session data since it may have changed outside the
|
||||
// current socket's request.
|
||||
if ( this.shouldLoadSessionOnEvent && listeners.isNotEmpty() ) {
|
||||
await this.session.load()
|
||||
const session = this.request.hasKey(Session) ? this.request.make<Session>(Session) : undefined
|
||||
if ( this.shouldLoadSessionOnEvent && session && listeners.isNotEmpty() ) {
|
||||
await session.load()
|
||||
}
|
||||
|
||||
await listeners.awaitMapCall('handler', payload)
|
||||
|
||||
// Persist any changes to the session for other requests.
|
||||
if ( this.shouldLoadSessionOnEvent && listeners.isNotEmpty() ) {
|
||||
await this.session.persist()
|
||||
if ( this.shouldLoadSessionOnEvent && session && listeners.isNotEmpty() ) {
|
||||
await session.persist()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user