badmfck-api-server 4.0.90 → 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.
@@ -97,7 +97,7 @@ async function Initializer(services) {
97
97
  }
98
98
  exports.Initializer = Initializer;
99
99
  class APIService extends BaseService_1.BaseService {
100
- version = "4.0.88";
100
+ version = "4.0.92";
101
101
  options;
102
102
  monitor = null;
103
103
  started = new Date();
@@ -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 = 5;
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" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.0.90",
3
+ "version": "4.0.92",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",