@arcblock/ws 1.18.61 → 1.18.62

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,6 +58,7 @@ class WsServer extends EventEmitter {
58
58
  this.authenticate = opts.authenticate || null;
59
59
  this.hooks = Object.assign({}, defaultHooks, opts.hooks || {});
60
60
  this.logger = opts.logger || createLogger('server', opts.silent);
61
+ this.skipLogOnHookError = opts.skipLogOnHookError || false;
61
62
  this.heartbeatTimeout = opts.heartbeatTimeout || HEARTBEAT_TIMEOUT;
62
63
 
63
64
  this.wss = new WebSocket.Server({ noServer: true, clientTracking: false });
@@ -163,7 +164,9 @@ class WsServer extends EventEmitter {
163
164
  try {
164
165
  await this.hooks.postBroadcast(opts);
165
166
  } catch (error) {
166
- this.logger.error('postBroadcast error', { error });
167
+ if (!this.skipLogOnHookError) {
168
+ this.logger.error('postBroadcast error', { error });
169
+ }
167
170
  }
168
171
  }
169
172
 
@@ -255,7 +258,9 @@ class WsServer extends EventEmitter {
255
258
  try {
256
259
  await this.hooks.postSend({ topic, event, data, options });
257
260
  } catch (error) {
258
- this.logger.error('postSend error', { error });
261
+ if (!this.skipLogOnHookError) {
262
+ this.logger.error('postSend error', { error });
263
+ }
259
264
  }
260
265
  }
261
266
 
@@ -307,7 +312,9 @@ class WsServer extends EventEmitter {
307
312
  socket.channel[topic] = {};
308
313
  socket.channel[topic].authInfo = authInfo;
309
314
  } catch (error) {
310
- this.logger.error('preJoinChannel error', { error });
315
+ if (!this.skipLogOnHookError) {
316
+ this.logger.error('preJoinChannel error', { error });
317
+ }
311
318
  reply(socket, topic, `chan_reply_${ref}`, { message: error.message }, 'error');
312
319
  return;
313
320
  }
@@ -325,7 +332,9 @@ class WsServer extends EventEmitter {
325
332
  try {
326
333
  await this.hooks.postJoinChannel({ socket, joinRef, ref, topic, event, payload });
327
334
  } catch (error) {
328
- this.logger.error('postJoinChannel error', { error });
335
+ if (!this.skipLogOnHookError) {
336
+ this.logger.error('postJoinChannel error', { error });
337
+ }
329
338
  }
330
339
 
331
340
  return;
@@ -336,7 +345,9 @@ class WsServer extends EventEmitter {
336
345
  try {
337
346
  await this.hooks.preLeaveChannel({ socket, joinRef, ref, topic, event, payload });
338
347
  } catch (error) {
339
- this.logger.error('preLeaveChannel error', { error });
348
+ if (!this.skipLogOnHookError) {
349
+ this.logger.error('preLeaveChannel error', { error });
350
+ }
340
351
  reply(socket, topic, `chan_reply_${ref}`, { message: error.message }, 'error');
341
352
  return;
342
353
  }
@@ -349,7 +360,9 @@ class WsServer extends EventEmitter {
349
360
  try {
350
361
  await this.hooks.postLeaveChannel({ socket, joinRef, ref, topic, event, payload });
351
362
  } catch (error) {
352
- this.logger.error('postLeaveChannel error', { error });
363
+ if (!this.skipLogOnHookError) {
364
+ this.logger.error('postLeaveChannel error', { error });
365
+ }
353
366
  }
354
367
 
355
368
  return;
@@ -359,7 +372,9 @@ class WsServer extends EventEmitter {
359
372
  try {
360
373
  await this.hooks.receiveMessage({ socket, joinRef, ref, topic, event, payload });
361
374
  } catch (error) {
362
- this.logger.error('receiveMessage error', { error });
375
+ if (!this.skipLogOnHookError) {
376
+ this.logger.error('receiveMessage error', { error });
377
+ }
363
378
  reply(socket, topic, `chan_reply_${ref}`, { message: error.message }, 'error');
364
379
  return;
365
380
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ws",
3
- "version": "1.18.61",
3
+ "version": "1.18.62",
4
4
  "description": "OCAP Chain websocket server and client",
5
5
  "keywords": [
6
6
  "websocket"
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/ArcBlock/asset-chain/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@arcblock/event-hub": "1.18.61",
37
+ "@arcblock/event-hub": "1.18.62",
38
38
  "debug": "^4.3.4",
39
39
  "eventemitter3": "^4.0.7",
40
40
  "lodash": "^4.17.21",
@@ -45,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "get-port": "^5.1.1"
47
47
  },
48
- "gitHead": "350ee5dcb48f4c335e13b59866fd1ad3f4189bfc"
48
+ "gitHead": "ee71440e5a1bd0888e82e9b2029af456a048de4e"
49
49
  }