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:
1065
package-lock.json
generated
1065
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -56,7 +56,7 @@ let ae_loc_init: key_val = {
|
||||
// properties: params, route, url
|
||||
// functions: fetch, setHeaders, parent, depends, untrack
|
||||
export async function load({ fetch, params, parent, route, url }) { // params, route, url
|
||||
let log_lvl: number = 0;
|
||||
let log_lvl: number = 2;
|
||||
// console.log(`Svelte root +layout.ts params:`, params);
|
||||
// console.log(`Svelte root +layout.ts route:`, route);
|
||||
// console.log(`Svelte root +layout.ts url:`, url);
|
||||
@@ -134,6 +134,7 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
|
||||
account_id = await core_func.handle_load_ae_obj_id__site_domain({
|
||||
api_cfg: ae_api_init,
|
||||
// fqdn: 'idaa.localhost:5173', // url.host,
|
||||
fqdn: url.host,
|
||||
try_cache: false,
|
||||
log_lvl: log_lvl
|
||||
@@ -203,20 +204,32 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
||||
|
||||
return site_domain_results.account_id_random;
|
||||
}
|
||||
console.log(`root +layout.ts: Site domain results not found!!!`)
|
||||
console.log(`root +layout.ts: Site domain results not found!!! URL = `, url);
|
||||
return null; // For no results
|
||||
|
||||
return null;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(`root +layout.ts: Site domain lookup error = `, error);
|
||||
// error(500, {
|
||||
// message: 'Site lookup failed!'
|
||||
// });
|
||||
return false; // For a likely API or DB connection error
|
||||
});
|
||||
|
||||
if (!account_id) {
|
||||
|
||||
if (await account_id === null) {
|
||||
console.log(`root +layout.ts: The account_id was not found in API response!!!`);
|
||||
// return false;
|
||||
// return;
|
||||
|
||||
error(500, {
|
||||
message: 'Account ID not found'
|
||||
message: 'The account ID was not found!'
|
||||
});
|
||||
} else if (await account_id === false) {
|
||||
console.log(`root +layout.ts: The API site lookup may have failed!!!`);
|
||||
|
||||
error(500, {
|
||||
message: 'Site lookup failed! Check the API.'
|
||||
});
|
||||
}
|
||||
// console.log(ae_loc_init);
|
||||
|
||||
ae_acct['api'] = ae_api_init;
|
||||
ae_acct['loc'] = ae_loc_init;
|
||||
|
||||
Reference in New Issue
Block a user