@resolveio/server-lib 20.14.15 → 20.14.16

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.
@@ -49,6 +49,7 @@ export declare class SubscriptionManager {
49
49
  private readonly LATENCY_UPDATE_INTERVAL;
50
50
  private readonly LATENCY_UPDATE_THRESHOLD_MS;
51
51
  private readonly LATENCY_DEBUG_THRESHOLD_MS;
52
+ private readonly PUBLICATION_DEBUG_THRESHOLD_MS;
52
53
  private _invalidationDebounceTimers;
53
54
  private _invalidationPendingTimestamps;
54
55
  private _pendingInvalidations;
@@ -160,6 +160,7 @@ var SubscriptionManager = /** @class */ (function () {
160
160
  // Minimum time difference between two latency updates for the same user
161
161
  this.LATENCY_UPDATE_THRESHOLD_MS = 30000;
162
162
  this.LATENCY_DEBUG_THRESHOLD_MS = 1000;
163
+ this.PUBLICATION_DEBUG_THRESHOLD_MS = 300;
163
164
  // private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];
164
165
  // private idPerformance: number = 0;
165
166
  // private performanceThread;
@@ -1739,12 +1740,13 @@ var SubscriptionManager = /** @class */ (function () {
1739
1740
  };
1740
1741
  SubscriptionManager.prototype.sendDataToOne = function (ws, messageId, sub, collection, type) {
1741
1742
  return __awaiter(this, void 0, void 0, function () {
1742
- var monitor, dependencySnapshot, res, execution, serverRes, err_1, _a, normalizedError, correlationId, serverRes, errorPayload;
1743
+ var startMs, monitor, dependencySnapshot, res, execution, serverRes, err_1, _a, normalizedError, correlationId, serverRes, errorPayload, durationMs;
1743
1744
  var _this = this;
1744
1745
  var _b;
1745
1746
  return __generator(this, function (_c) {
1746
1747
  switch (_c.label) {
1747
1748
  case 0:
1749
+ startMs = Date.now();
1748
1750
  monitor = this._monitorManagerFunction.startMonitorFunction('User Specific Publication', sub.publication, '', '', sub.subscriptionData);
1749
1751
  _c.label = 1;
1750
1752
  case 1:
@@ -1811,7 +1813,22 @@ var SubscriptionManager = /** @class */ (function () {
1811
1813
  case 4:
1812
1814
  _c.sent();
1813
1815
  return [3 /*break*/, 7];
1814
- case 5: return [4 /*yield*/, this._monitorManagerFunction.finishMonitorFunction(monitor)];
1816
+ case 5:
1817
+ durationMs = Date.now() - startMs;
1818
+ if (durationMs >= this.PUBLICATION_DEBUG_THRESHOLD_MS) {
1819
+ console.log(new Date(), '[Slow Publication]', {
1820
+ durationMs: durationMs,
1821
+ publication: sub.publication,
1822
+ type: type,
1823
+ collection: collection,
1824
+ userSpecific: true,
1825
+ id_user: ws['id_user'] || null,
1826
+ id_ws: ws['id_socket'] || null,
1827
+ clients: sub.clients ? sub.clients.length : 0,
1828
+ subscriptionData: sub.subscriptionData
1829
+ });
1830
+ }
1831
+ return [4 /*yield*/, this._monitorManagerFunction.finishMonitorFunction(monitor)];
1815
1832
  case 6:
1816
1833
  _c.sent();
1817
1834
  return [7 /*endfinally*/];
@@ -1823,7 +1840,7 @@ var SubscriptionManager = /** @class */ (function () {
1823
1840
  // Fetch pub once, send to all clients linked to this pub
1824
1841
  SubscriptionManager.prototype.sendDataToAll = function (sub, collection, type) {
1825
1842
  return __awaiter(this, void 0, void 0, function () {
1826
- var subIndex, monitor, res_1, dependencySnapshot, execution, cacheData, _a, _b, client, ws, serverRes, _c, _d, client, ws, serverRes, nodeCacheSize, deleteCount, subArr, zz, err_2, _e, normalizedError, correlationId, _f, _g, client, ws, serverRes, errorPayload;
1843
+ var subIndex, startMs, monitor, res_1, dependencySnapshot, execution, cacheData, _a, _b, client, ws, serverRes, _c, _d, client, ws, serverRes, nodeCacheSize, deleteCount, subArr, zz, err_2, _e, normalizedError, correlationId, _f, _g, client, ws, serverRes, errorPayload, durationMs;
1827
1844
  var e_6, _h, e_7, _j, e_8, _k;
1828
1845
  var _this = this;
1829
1846
  var _l;
@@ -1841,6 +1858,7 @@ var SubscriptionManager = /** @class */ (function () {
1841
1858
  }
1842
1859
  return [2 /*return*/];
1843
1860
  case 1:
1861
+ startMs = Date.now();
1844
1862
  monitor = this._monitorManagerFunction.startMonitorFunction('Publication', sub.publication, '', '', sub.subscriptionData);
1845
1863
  dependencySnapshot = void 0;
1846
1864
  _m.label = 2;
@@ -2035,7 +2053,21 @@ var SubscriptionManager = /** @class */ (function () {
2035
2053
  case 5:
2036
2054
  _m.sent();
2037
2055
  return [3 /*break*/, 8];
2038
- case 6: return [4 /*yield*/, this._monitorManagerFunction.finishMonitorFunction(monitor)];
2056
+ case 6:
2057
+ durationMs = Date.now() - startMs;
2058
+ if (durationMs >= this.PUBLICATION_DEBUG_THRESHOLD_MS) {
2059
+ console.log(new Date(), '[Slow Publication]', {
2060
+ durationMs: durationMs,
2061
+ publication: sub.publication,
2062
+ type: type,
2063
+ collection: collection,
2064
+ userSpecific: false,
2065
+ clients: sub.clients ? sub.clients.length : 0,
2066
+ cacheId: sub.cacheId || 0,
2067
+ subscriptionData: sub.subscriptionData
2068
+ });
2069
+ }
2070
+ return [4 /*yield*/, this._monitorManagerFunction.finishMonitorFunction(monitor)];
2039
2071
  case 7:
2040
2072
  _m.sent();
2041
2073
  return [7 /*endfinally*/];