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