diff --git a/package.json b/package.json index a3f4549..0ed194f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/support/bus/WebSocketBus.ts b/src/support/bus/WebSocketBus.ts index f487dc1..d70ddbc 100644 --- a/src/support/bus/WebSocketBus.ts +++ b/src/support/bus/WebSocketBus.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) : 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() } }