zyket 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyket",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -31,7 +31,7 @@ module.exports = class SocketIO extends Service {
31
31
 
32
32
  this.io = new Server({ cors: { origin: "*" }, maxHttpBufferSize: 10 * 1024 * 1024 });
33
33
 
34
- this.io.on("connection", (socket) => {
34
+ this.io.on("connection", async (socket) => {
35
35
  const connectionGuards = (connectionHandler?.guards || []).map(mdl => this.guards[mdl])
36
36
  for (const guard of connectionGuards) {
37
37
  if(!guard) {
@@ -40,7 +40,13 @@ module.exports = class SocketIO extends Service {
40
40
  }
41
41
  guard.handle({ container: this.#container, socket, io: this.io });
42
42
  }
43
- connectionHandler.handle({ container: this.#container, socket, io: this.io });
43
+ try {
44
+ await connectionHandler.handle({ container: this.#container, socket, io: this.io });
45
+ } catch(e) {
46
+ this.#container.get('logger').error(`Error in connection handler for socket ${socket.id}: ${e.message}`);
47
+ socket.disconnect(true);
48
+ return;
49
+ }
44
50
  handlers.forEach((handler) => {
45
51
  const handlerGuards = (handler?.guards || []).map(mdl => this.guards[mdl])
46
52
  socket.on(handler.event, async (data, callback) => {