Trying to track down a bug that is happening when run in Docker. Pretty sure it is related to a DNS resolution thing. The GET Object function shows better information if something goes wrong.

This commit is contained in:
Scott Idem
2025-01-06 16:24:47 -05:00
parent b64e7a6b8a
commit 92af1a5962
4 changed files with 596 additions and 530 deletions

View File

@@ -162,10 +162,13 @@ export async function get_ae_obj_id_crud(
params: params,
timeout: timeout,
log_lvl: log_lvl
});
})
.catch(function (error) {
console.log('API GET CRUD object ID request failed.', error);
});
if (log_lvl > 1) {
console.log(object_obj_get_promise);
console.log('GET Object result =', object_obj_get_promise);
}
return object_obj_get_promise;

View File

@@ -72,12 +72,12 @@ export let get_object = async function get_object(
headers[prop] = JSON.stringify(headers[prop]);
}
headers_cleaned[prop_cleaned] = headers[prop];
if (log_lvl) {
if (log_lvl > 1) {
console.log(`${prop_cleaned}: ${headers_cleaned[prop_cleaned]}`);
}
}
headers = headers_cleaned;
if (log_lvl) {
if (log_lvl > 1) {
console.log('All headers cleaned:', headers);
}
@@ -90,18 +90,32 @@ export let get_object = async function get_object(
signal: controller.signal
};
if (log_lvl) {
if (log_lvl > 1) {
console.log('Fetch options:', fetchOptions);
}
for (let attempt = 1; attempt <= retry_count; attempt++) {
try {
const response = await fetch(url.toString(), fetchOptions);
const response = await fetch(url.toString(), fetchOptions)
.catch(function (error) {
console.log('API GET Object *fetch* request was aborted or failed in an unexpected way.', error);
});
clearTimeout(timeoutId);
if (!response) {
if (log_lvl > 1) {
console.log('API GET Object: Something went wrong with *fetch* request. Returning false? Throwing an error!');
}
throw new Error(`HTTP fetch request was aborted or failed in an unexpected way! URL = ${url.toString()}`); // This will allow it to retry
// return false; // This will stop the retries
}
if (log_lvl) {
console.log(`Response: status=${response.status} statusText=${response.statusText} url=${response.url} attempt=${attempt}`);
}
if (log_lvl > 1) {
console.log('Response:', response);
}
if (!response.ok) {
if (response.status === 404) {
@@ -110,6 +124,7 @@ export let get_object = async function get_object(
}
return null;
}
console.log('The response was not ok. Throwing an error!');
throw new Error(`HTTP error! status: ${response.status}`);
}
@@ -175,7 +190,7 @@ export let get_object = async function get_object(
}
} catch (error) {
if (log_lvl) {
console.log(`Fetch error on attempt ${attempt}:`, error);
console.log(`API GET object request *fetch* error on attempt ${attempt}:`, error);
}
if (attempt === retry_count) {
return false;