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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user