Skip to content

Troubleshooting

Batch is stuck

The system is stabilised at this point to detect and auto restart batches if stuck or any errors.

However, if the issue is due to a programmical error and there is no way for the system to fix this itself, the developer will need to manually investigate the batch and fix the issues that come up in the console.

This can be done by using the restartBatch helper

typescript
import '#app/Core/bootstrap.js'
import restartBatch from '#app/Services/Batch/RestartBatch.js';

const db = await getDb()

const batch = await db.models.linkLeadsBatches.qb().eq('id', 12345)
await restartBatch(batch);

// logs and errors will be outputted to the console.

Emails are stuck / Emails need to be resynced

Similar to the batch issue, the system is stabilised to detect and auto restart emails if stuck or any errors.

However, in some cases a programmical or phasing error may manifest that requires the developer to further investigate and fix the issue.

Further, in some cases it may be desirable to force-sync specific email accounts to a specific date.

To do either cases, the startEmailReadProcess helper can be used.

typescript
import '#app/Core/bootstrap.js'
import { startEmailReadProcess } from '#app/Services/Emails/StartEmailReadProcess.js';

const accounts = await db.models.emailAccounts.qb()
  .gte('last_checked', moment().subtract(2, 'day').format('YYYY-MM-DD HH:mm:ss'))
  .order('id', 'asc')
  .all()

console.log('Email accounts to check: ', accounts.length);
for (const account of accounts) {
  console.log('Starting ' + account.id)
  await startEmailReadProcess(account)
  console.log('Completed ' + account.id)
}

Metrics have no values

99.99% of the time this is due to credits running out on a specific metric provider. Finance would need to clear the balance, and then this will be functional again.

Usually a number of batches would have failed and it would be too labour intensive to require linkdev's to manually recreate batches.

Therefore to fix these, running a script to pull in the failed batches is appropriate.

typescript
import '#app/Core/bootstrap.js'
import restartBatch from '#app/Services/Batch/RestartBatch.js';

const db = await getDb()

const bts = await db.models.linkLeadsBatches.qb()
  .eq('status', ['error', 'failed', 'empty'])
  
  // Adding a date filter is appropriate so that batches much further in the past are not restarted since geniune empty batches are not uncommon
  .gte('created_at', '2024-03-13 00:00:00')
  .all()

console.log(`Restarting ${bts.length} batches`)
for (const b of bts) {
  await restartBatch(b);
}

No clients available for Google accounts

Due to the way our gmail integration works, at times when authenticating new accounts the end user may get a 'no clients available' message.

As the is no way to know programmatically how many users are available for each registered app, the system always decrements the availability even if an account has already been authenticated to that app.

To fix this, the developer needs to login to each available app instance and manually check the counts.

Then, the developer needs to reflect these accounts on the gmail_clients in the database.

If all accounts have no available users, the developer will need to create additional apps in Google Console and add these to the database.