@machinemetrics/mm-erp-sdk 0.1.1-beta.1 → 0.1.1-beta.3

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.
@@ -143,10 +143,23 @@ class AxiosClient {
143
143
  data: config2.data,
144
144
  params: config2.params
145
145
  };
146
+ logger.info("HTTP request starting", {
147
+ url: config2.url,
148
+ method: config2.method,
149
+ baseURL: this.client.defaults.baseURL,
150
+ retryAttempts: this.retryAttempts
151
+ });
152
+ console.log("=== FULL URL DEBUG ===");
153
+ console.log("baseURL:", this.client.defaults.baseURL);
154
+ console.log("relative url:", config2.url);
155
+ console.log("full constructed URL:", (this.client.defaults.baseURL || "") + config2.url);
156
+ console.log("method:", config2.method);
146
157
  let lastError;
147
158
  for (let attempt = 0; attempt <= this.retryAttempts; attempt++) {
148
159
  try {
160
+ logger.info(`HTTP request attempt ${attempt + 1}/${this.retryAttempts + 1}`);
149
161
  const response = await this.client.request(axiosConfig);
162
+ logger.info("HTTP request succeeded", { status: response.status });
150
163
  return {
151
164
  data: response.data,
152
165
  status: response.status,
@@ -154,16 +167,28 @@ class AxiosClient {
154
167
  };
155
168
  } catch (error) {
156
169
  lastError = error;
170
+ logger.info(`HTTP request attempt ${attempt + 1} failed`, {
171
+ errorType: typeof error,
172
+ errorConstructor: error?.constructor?.name,
173
+ isAxiosError: error instanceof AxiosError,
174
+ message: error instanceof Error ? error.message : String(error),
175
+ code: error?.code,
176
+ status: error?.response?.status
177
+ });
157
178
  if (error instanceof AxiosError && error.response?.status && error.response.status >= 400 && error.response.status < 500) {
179
+ logger.info("Not retrying due to 4xx client error");
158
180
  break;
159
181
  }
160
182
  if (attempt < this.retryAttempts) {
183
+ const waitTime = Math.pow(2, attempt) * 1e3;
184
+ logger.info(`Waiting ${waitTime}ms before retry`);
161
185
  await new Promise(
162
186
  (resolve) => setTimeout(resolve, Math.pow(2, attempt) * 1e3)
163
187
  );
164
188
  }
165
189
  }
166
190
  }
191
+ logger.info("HTTP request failed after all retries, throwing error");
167
192
  throw this.handleError(lastError, config2);
168
193
  }
169
194
  handleError(error, requestConfig) {