badmfck-api-server 4.0.89 → 4.0.92
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.
|
@@ -246,7 +246,7 @@ class DBService extends BaseService_1.BaseService {
|
|
|
246
246
|
if (value === null || value === undefined)
|
|
247
247
|
return 'NULL';
|
|
248
248
|
const stringValue = typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
249
|
-
return stringValue.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, (char) => {
|
|
249
|
+
return "'" + stringValue.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, (char) => {
|
|
250
250
|
switch (char) {
|
|
251
251
|
case "\0": return "\\0";
|
|
252
252
|
case "\x08": return "\\b";
|
|
@@ -261,7 +261,7 @@ class DBService extends BaseService_1.BaseService {
|
|
|
261
261
|
return "\\" + char;
|
|
262
262
|
default: return char;
|
|
263
263
|
}
|
|
264
|
-
});
|
|
264
|
+
}) + "'";
|
|
265
265
|
}
|
|
266
266
|
return adapter.escape(value);
|
|
267
267
|
}
|
|
@@ -61,7 +61,7 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
61
61
|
const url = this.options.host + "/__ms_host_control/receiver";
|
|
62
62
|
const ts = Date.now().toString();
|
|
63
63
|
const nonce = crypto_1.default.randomBytes(12).toString("hex");
|
|
64
|
-
const maxAttempts =
|
|
64
|
+
const maxAttempts = 10;
|
|
65
65
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
66
66
|
const rawSecret = Buffer.from(this.options.securityKey, "base64");
|
|
67
67
|
const key = crypto_1.default.createHash("sha256").update(rawSecret).digest();
|
|
@@ -79,18 +79,23 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
79
79
|
"x-microservice-ts": ts,
|
|
80
80
|
"x-microservice-nonce": nonce
|
|
81
81
|
};
|
|
82
|
+
console.log(`Microservice call attempt ${attempt}: Sending request to ${url} with id: ${req.id}, requestName: ${req.requestName}`);
|
|
82
83
|
const resp = await Http_1.Http.post(url, {
|
|
83
84
|
tag: tag.toString("base64"),
|
|
84
85
|
enc: encrypted.toString("base64")
|
|
85
86
|
}, { headers });
|
|
86
87
|
if (!resp.ok && resp.details?.network) {
|
|
88
|
+
console.log(`Network error on microservice call attempt ${attempt}:`, resp);
|
|
87
89
|
if (attempt < maxAttempts) {
|
|
90
|
+
console.log(`Retrying microservice call... (attempt ${attempt}/${maxAttempts})`);
|
|
88
91
|
TimeframeService_1.TimeframeService.wait(500);
|
|
89
92
|
continue;
|
|
90
93
|
}
|
|
94
|
+
console.log(`Microservice call failed after ${attempt} attempts due to network errors.`);
|
|
91
95
|
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, details: "Network connection lost after multiple retries, attempts: " + attempt };
|
|
92
96
|
}
|
|
93
97
|
if (!resp.ok) {
|
|
98
|
+
console.log(`Microservice call error response:`, resp);
|
|
94
99
|
const remoteError = resp.error?.error;
|
|
95
100
|
if (DefaultErrors_1.ErrorUtils.isError(remoteError))
|
|
96
101
|
return remoteError;
|
|
@@ -99,12 +104,15 @@ class MicroserviceClient extends BaseService_1.BaseService {
|
|
|
99
104
|
const body = resp.data;
|
|
100
105
|
const isAccepted = body?.error?.code === DefaultErrors_1.default.ACCEPTED.code || body?.code === DefaultErrors_1.default.ACCEPTED.code;
|
|
101
106
|
if (isAccepted) {
|
|
107
|
+
console.log(`Microservice call accepted, polling for result... (attempt ${attempt}/${maxAttempts})`);
|
|
102
108
|
if (attempt < maxAttempts) {
|
|
103
109
|
TimeframeService_1.TimeframeService.wait(500);
|
|
104
110
|
continue;
|
|
105
111
|
}
|
|
112
|
+
console.log(`Microservice call timed out after ${attempt} attempts.`);
|
|
106
113
|
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, details: "Microservice processing timeout, attempts: " + attempt };
|
|
107
114
|
}
|
|
115
|
+
console.log(`Microservice call completed with response:`, body);
|
|
108
116
|
return (body && typeof body === "object" && "error" in body) ? body.error : (body.data ?? null);
|
|
109
117
|
}
|
|
110
118
|
return { ...DefaultErrors_1.default.EXTERNAL_SERVICE_ERROR, details: "Unknown polling error" };
|