@resolveio/server-lib 20.14.33 → 20.14.35
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.
|
@@ -25,6 +25,7 @@ export declare class SubscriptionManager {
|
|
|
25
25
|
private _monitorManagerFunction;
|
|
26
26
|
private _enableDebug;
|
|
27
27
|
private _enableDependencyDebug;
|
|
28
|
+
private _connectDebug;
|
|
28
29
|
private _debugOplogCollections;
|
|
29
30
|
private _debugOplogHits;
|
|
30
31
|
private _debugSubCollections;
|
|
@@ -94,7 +95,10 @@ export declare class SubscriptionManager {
|
|
|
94
95
|
private resolveOplogMode;
|
|
95
96
|
private resolveLocalOplogResyncIntervalMs;
|
|
96
97
|
private resolveResumeTokenMaxAgeMs;
|
|
98
|
+
private resolveConnectDebug;
|
|
99
|
+
private parseDebugFlag;
|
|
97
100
|
private parsePositiveNumber;
|
|
101
|
+
private connectDebug;
|
|
98
102
|
private parsePositiveFloat;
|
|
99
103
|
private isChangeStreamUnsupported;
|
|
100
104
|
private isResumeTokenInvalid;
|
|
@@ -134,6 +134,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
134
134
|
this._heapSize = resolveHeapLimitBytes();
|
|
135
135
|
this._enableDebug = false;
|
|
136
136
|
this._enableDependencyDebug = false;
|
|
137
|
+
this._connectDebug = false;
|
|
137
138
|
this._debugOplogCollections = [];
|
|
138
139
|
this._debugOplogHits = 0;
|
|
139
140
|
this._debugSubCollections = [];
|
|
@@ -224,6 +225,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
224
225
|
// }, 10000);
|
|
225
226
|
this.serverConfig = serverConfig;
|
|
226
227
|
this._wss = wss;
|
|
228
|
+
this._connectDebug = this.resolveConnectDebug();
|
|
227
229
|
this._oplogMode = this.resolveOplogMode();
|
|
228
230
|
this._localOplogResyncIntervalMs = this.resolveLocalOplogResyncIntervalMs();
|
|
229
231
|
this.registerCorePublications();
|
|
@@ -947,6 +949,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
947
949
|
switch (_a.label) {
|
|
948
950
|
case 0:
|
|
949
951
|
this._debugSubHits += 1;
|
|
952
|
+
this.connectDebug('Subscribe request', {
|
|
953
|
+
publication: publication,
|
|
954
|
+
messageRoute: messageRoute,
|
|
955
|
+
messageId: messageId,
|
|
956
|
+
id_socket: ws ? ws['id_socket'] : null,
|
|
957
|
+
user: ws ? ws['user'] : null,
|
|
958
|
+
args: Array.isArray(subscriptionData) ? subscriptionData.length : 0
|
|
959
|
+
});
|
|
950
960
|
if (!this._debugSubCollections.some(function (a) { return a.publication === publication; })) {
|
|
951
961
|
this._debugSubCollections.push({
|
|
952
962
|
publication: publication,
|
|
@@ -959,15 +969,18 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
959
969
|
pub = this._publications[publication];
|
|
960
970
|
if (!!pub) return [3 /*break*/, 1];
|
|
961
971
|
console.error(new Date(), 'No Publication: ' + publication);
|
|
972
|
+
this.connectDebug('Missing publication', { publication: publication, messageRoute: messageRoute, messageId: messageId });
|
|
962
973
|
return [2 /*return*/];
|
|
963
974
|
case 1:
|
|
964
975
|
if (subscriptionData.length > 1 || subscriptionData[0]) {
|
|
965
976
|
if (!pub.check) {
|
|
966
977
|
console.error(new Date(), 'No Check Function For Pub ' + publication);
|
|
978
|
+
this.connectDebug('Missing check for publication', { publication: publication, messageRoute: messageRoute, messageId: messageId });
|
|
967
979
|
return [2 /*return*/];
|
|
968
980
|
}
|
|
969
981
|
else if (!pub.check._schema) {
|
|
970
982
|
console.error(new Date(), 'No Check Schema For Pub ' + publication);
|
|
983
|
+
this.connectDebug('Missing check schema for publication', { publication: publication, messageRoute: messageRoute, messageId: messageId });
|
|
971
984
|
return [2 /*return*/];
|
|
972
985
|
}
|
|
973
986
|
else {
|
|
@@ -983,6 +996,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
983
996
|
catch (errors) {
|
|
984
997
|
if (errors) {
|
|
985
998
|
console.error(new Date(), 'Error in Pub Check (' + publication + ')', errors);
|
|
999
|
+
this.connectDebug('Publication check failed', {
|
|
1000
|
+
publication: publication,
|
|
1001
|
+
messageRoute: messageRoute,
|
|
1002
|
+
messageId: messageId,
|
|
1003
|
+
args: subscriptionData.length,
|
|
1004
|
+
valObj: valObj,
|
|
1005
|
+
error: (errors === null || errors === void 0 ? void 0 : errors.message) || errors
|
|
1006
|
+
});
|
|
986
1007
|
return [2 /*return*/];
|
|
987
1008
|
}
|
|
988
1009
|
}
|
|
@@ -1202,6 +1223,30 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1202
1223
|
|| config['SUBSCRIPTION_OPLOG_RESUME_TOKEN_MAX_AGE_MS'];
|
|
1203
1224
|
return this.parsePositiveNumber(raw);
|
|
1204
1225
|
};
|
|
1226
|
+
SubscriptionManager.prototype.resolveConnectDebug = function () {
|
|
1227
|
+
var config = this.serverConfig || resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
1228
|
+
var raw = process.env.WS_CONNECT_DEBUG
|
|
1229
|
+
|| process.env.CONNECT_DEBUG
|
|
1230
|
+
|| config['WS_CONNECT_DEBUG']
|
|
1231
|
+
|| config['CONNECT_DEBUG'];
|
|
1232
|
+
return this.parseDebugFlag(raw);
|
|
1233
|
+
};
|
|
1234
|
+
SubscriptionManager.prototype.parseDebugFlag = function (value) {
|
|
1235
|
+
if (value === true) {
|
|
1236
|
+
return true;
|
|
1237
|
+
}
|
|
1238
|
+
if (value === false || value === null || value === undefined) {
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
if (typeof value === 'number') {
|
|
1242
|
+
return value === 1;
|
|
1243
|
+
}
|
|
1244
|
+
if (typeof value === 'string') {
|
|
1245
|
+
var normalized = value.trim().toLowerCase();
|
|
1246
|
+
return ['1', 'true', 'yes', 'y', 'on'].includes(normalized);
|
|
1247
|
+
}
|
|
1248
|
+
return false;
|
|
1249
|
+
};
|
|
1205
1250
|
SubscriptionManager.prototype.parsePositiveNumber = function (value) {
|
|
1206
1251
|
if (typeof value === 'number' && Number.isFinite(value) && value > 0) {
|
|
1207
1252
|
return value;
|
|
@@ -1214,6 +1259,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
1214
1259
|
}
|
|
1215
1260
|
return 0;
|
|
1216
1261
|
};
|
|
1262
|
+
SubscriptionManager.prototype.connectDebug = function (message, details) {
|
|
1263
|
+
if (!this._connectDebug) {
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
if (details) {
|
|
1267
|
+
console.log(new Date(), '[Connect Debug]', message, JSON.stringify(details));
|
|
1268
|
+
}
|
|
1269
|
+
else {
|
|
1270
|
+
console.log(new Date(), '[Connect Debug]', message);
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1217
1273
|
SubscriptionManager.prototype.parsePositiveFloat = function (value) {
|
|
1218
1274
|
if (typeof value === 'number' && Number.isFinite(value) && value > 0) {
|
|
1219
1275
|
return value;
|