diff --git a/server/src/services/sheriffService.ts b/server/src/services/sheriffService.ts index c007c54..e3a83cf 100644 --- a/server/src/services/sheriffService.ts +++ b/server/src/services/sheriffService.ts @@ -228,6 +228,8 @@ export class SheriffService { if (loadRutData == null) { console.error('loadRutData failed is null'); + await logEntry.save(); + return logEntry.toObject(); } //must wait at least 30 seconds before starting the next await new Promise(resolve => setTimeout(resolve, parseInt(process.env.SHERIFF_API_DELAY || '30000'))); @@ -235,6 +237,12 @@ export class SheriffService { const summaryData = await makeApiCall('summaryData', 'get', `/helper/${sanitizedRut}/summary?complete=true`); //added complete true console.log(`[DEBUG] After summaryData call, sanitizedRut is still: ${sanitizedRut}`); + if (summaryData == null) { + console.error('summaryData failed is null'); + await logEntry.save(); + return logEntry.toObject(); + } + let societaryMeshExternal: any[] | null = null; if (summaryData.data.societaryMeshExternal && summaryData.data.societaryMeshExternal.length > 0) { diff --git a/server/src/services/sheriffV2Service.ts b/server/src/services/sheriffV2Service.ts index c589446..0c2fac8 100644 --- a/server/src/services/sheriffV2Service.ts +++ b/server/src/services/sheriffV2Service.ts @@ -227,6 +227,8 @@ export class sheriffV2Service { //console.log(`[DEBUG] loadRutData response RUT: ${loadRutData?.data?.rut || 'No RUT in response'}`); if (summaryData == null) { console.error('loadRutData failed is null'); + await logEntry.save(); + return logEntry.toObject(); } if(!summaryData.data) { summaryData.data = {};