@resolveio/server-lib 5.0.11 → 5.0.12-debug

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.
@@ -933,6 +933,7 @@ var SubscriptionManager = /** @class */ (function () {
933
933
  hasError: false,
934
934
  data: this._subCache.filter(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); })[0].res
935
935
  };
936
+ console.log('Cache1: ' + 'Found - ' + subscription.publication);
936
937
  this.sendWS(ws, serverRes);
937
938
  }
938
939
  else {
@@ -940,8 +941,8 @@ var SubscriptionManager = /** @class */ (function () {
940
941
  that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));
941
942
  }
942
943
  (_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
943
- if (common_1.getBinarySize(JSON.stringify(_this._subCache)) > 750000000) {
944
- var neededSize = (common_1.getBinarySize(JSON.stringify(_this._subCache))) - 750000000;
944
+ if (common_1.getBinarySize(JSON.stringify(_this._subCache)) > 500000000) {
945
+ var neededSize = (common_1.getBinarySize(JSON.stringify(_this._subCache))) - 500000000;
945
946
  var neededSizeIndex = 0;
946
947
  for (var zz = 0; zz < _this._subCache.length; zz++) {
947
948
  neededSize -= (common_1.getBinarySize(JSON.stringify(_this._subCache[zz])));
@@ -950,9 +951,11 @@ var SubscriptionManager = /** @class */ (function () {
950
951
  break;
951
952
  }
952
953
  }
954
+ console.log('Cache1: ' + 'Too Big - ' + subscription.publication);
953
955
  _this._subCache.splice(0, neededSizeIndex);
954
956
  }
955
957
  _this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, res: res });
958
+ console.log('Cache1: ' + 'Create - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
956
959
  var serverRes = {
957
960
  messageId: messageId,
958
961
  hasError: false,
@@ -1008,6 +1011,7 @@ var SubscriptionManager = /** @class */ (function () {
1008
1011
  hasError: false,
1009
1012
  data: _this._subCache.filter(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); })[0].res
1010
1013
  };
1014
+ console.log('Cache: ' + 'Found - ' + subscription.publication);
1011
1015
  _this.sendWS(ws, serverRes);
1012
1016
  }
1013
1017
  });
@@ -1018,8 +1022,8 @@ var SubscriptionManager = /** @class */ (function () {
1018
1022
  that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));
1019
1023
  }
1020
1024
  (_a = that._publications[subscription.publication].function).call.apply(_a, [Object.assign({}, that, SubscriptionManager.prototype)].concat(subscription.subscriptionData)).then(function (res) {
1021
- if (common_1.getBinarySize(JSON.stringify(_this._subCache)) > 750000000) {
1022
- var neededSize = (common_1.getBinarySize(JSON.stringify(_this._subCache))) - 750000000;
1025
+ if (common_1.getBinarySize(JSON.stringify(_this._subCache)) > 500000000) {
1026
+ var neededSize = (common_1.getBinarySize(JSON.stringify(_this._subCache))) - 500000000;
1023
1027
  var neededSizeIndex = 0;
1024
1028
  for (var zz = 0; zz < _this._subCache.length; zz++) {
1025
1029
  neededSize -= (common_1.getBinarySize(JSON.stringify(_this._subCache[zz])));
@@ -1028,9 +1032,11 @@ var SubscriptionManager = /** @class */ (function () {
1028
1032
  break;
1029
1033
  }
1030
1034
  }
1035
+ console.log('Cache: ' + 'Too Big - ' + subscription.publication);
1031
1036
  _this._subCache.splice(0, neededSizeIndex);
1032
1037
  }
1033
1038
  _this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, res: res });
1039
+ console.log('Cache: ' + 'Create - ' + subscription.publication + ' - ' + common_1.getBinarySize(JSON.stringify(_this._subCache)));
1034
1040
  subscription.clients.forEach(function (client) {
1035
1041
  that._wss.clients.forEach(function (ws) {
1036
1042
  if (ws['id_socket'] === client.id_socket) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "5.0.11",
3
+ "version": "5.0.12-debug",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/server-app.js CHANGED
@@ -334,6 +334,19 @@ var ResolveIOMainServer = /** @class */ (function () {
334
334
  ws.terminate();
335
335
  });
336
336
  });
337
+ process.stdout.on('error', function (err) {
338
+ if (err.code === "EPIPE") {
339
+ console.log('EPIPE error found => ignoring');
340
+ _this._wss.clients.forEach(function (ws) {
341
+ if (ws['isAlive'] === false) {
342
+ if (ws['retryCnt'] >= 60) {
343
+ _this.unsubscribeWS(ws);
344
+ ws.terminate();
345
+ }
346
+ }
347
+ });
348
+ }
349
+ });
337
350
  // Keep alive timer to ping/pong
338
351
  setInterval(function () {
339
352
  _this._wss.clients.forEach(function (ws) {