fixing logging issue

This commit is contained in:
Kumaraguru 2025-01-13 19:53:19 +00:00
parent 60a9576fbe
commit 458d0c9ce6
No known key found for this signature in database
GPG Key ID: 4E4555A84ECD28F7
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"name": "codexstorage",
"version": "1.0.8",
"version": "1.0.9",
"description": "CLI tool for Codex Storage",
"main": "index.js",
"type": "module",

View File

@ -53,14 +53,14 @@ export async function logToSupabase(nodeData, retryCount = 3, retryDelay = 1000)
port: nodeData.announceAddresses[0].split('/')[4],
listeningAddress: nodeData.table.localNode.address,
timestamp: new Date().toISOString(),
wallet: currentWallet // Include wallet address in payload
wallet: currentWallet
};
const response = await axios.post('https://vfcnsjxahocmzefhckfz.supabase.co/functions/v1/codexnodes', payload, {
headers: {
'Content-Type': 'application/json'
},
timeout: 5000 // 5 second timeout
timeout: 5000
});
return response.status === 200;
@ -69,7 +69,7 @@ export async function logToSupabase(nodeData, retryCount = 3, retryDelay = 1000)
const isNetworkError = error.code === 'ENOTFOUND' || error.code === 'ETIMEDOUT' || error.code === 'ECONNREFUSED';
if (isLastAttempt || !isNetworkError) {
console.error(`Failed to log to Supabase (attempt ${attempt}/${retryCount}):`, error.message);
console.error(`Failed to log node data (attempt ${attempt}/${retryCount}):`, error.message);
if (error.response) {
console.error('Error response:', {
status: error.response.status,
@ -79,7 +79,7 @@ export async function logToSupabase(nodeData, retryCount = 3, retryDelay = 1000)
if (isLastAttempt) return false;
} else {
// Only log retry attempts for network errors
console.log(`Retrying Supabase log (attempt ${attempt}/${retryCount}) after ${retryDelay}ms...`);
console.log(`Retrying to log data (attempt ${attempt}/${retryCount})...`);
await delay(retryDelay);
}
}
@ -115,7 +115,7 @@ export async function startPeriodicLogging() {
}
} catch (error) {
// Silently handle any logging errors to not disrupt the node operation
console.error('Failed to log node info:', error.message);
console.error('Failed to log node data:', error.message);
}
};