Fix async context loss in WebSocketBus

This commit is contained in:
Garrett Mills 2022-08-10 00:06:48 -05:00
parent 085fe04f90
commit 9b47d2ac99
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@extollo/lib",
"version": "0.13.8",
"version": "0.13.9",
"description": "The framework library that lifts up your code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

View File

@ -154,8 +154,10 @@ export class WebSocketBus implements EventBus, AwareOfContainerLifecycle {
})
})
this.ws.on('close', () => this.bus.push(new WebSocketCloseEvent()))
this.ws.on('error', () => this.bus.push(new WebSocketCloseEvent()))
this.ws.on('close', () =>
resource.runInAsyncScope(() => this.bus.push(new WebSocketCloseEvent())))
this.ws.on('error', () =>
resource.runInAsyncScope(() => this.bus.push(new WebSocketCloseEvent())))
await this.registerHealthCheck()