overleaf/overleaf · error

fatal error

Error message

fatal error

What it means

This is the top-level catch-all of the bulk_resync_file_fix_up script. Any uncaught error from the main flow (e.g. a rethrown flush failure, DB connection loss, iteration crash) is logged as 'fatal error' and the process exits with code 100. It is a wrapper, not a domain error; the real cause is in the logged err object.

Source

Thrown at services/project-history/scripts/bulk_resync_file_fix_up.mjs:325

try {
  try {
    await main()
  } finally {
    clearInterval(logInterval)
    logStats()
    Metrics.close()
    await mongoClient.close()
    // TODO(das7pad): graceful shutdown for redis. Refactor process.exit when done.
  }
  console.log('Done.')
  await setTimeout(1_000)
  if (STATS.failure) {
    process.exit(Math.min(STATS.failure, 99))
  } else {
    process.exit(0)
  }
} catch (err) {
  logger.err({ err }, 'fatal error')
  await setTimeout(1_000)
  process.exit(100)
}

View on GitHub (pinned to 28ad3b03b7)

Solutions

  1. Read the err field in the 'fatal error' log line to identify the root cause; exit code 100 only signals an unhandled crash.
  2. Re-run the script once mongo/redis connectivity and credentials are verified (the script is resumable/idempotent for remaining projects).
  3. Check STATS.failure counts in earlier logs to see how many projects failed before the crash.
  4. If crashes recur at the same project, inspect that project's data for corruption or malformed records.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await main()
} catch (err) {
  logger.err({ err, stack: err.stack, cause: err.cause }, 'fatal error')
  process.exitCode = 100
}

Prevention

When it happens

Trigger: Any throw escaping the main try block: rethrown flush errors during shutdown, mongo/redis connection failures, or bugs in the batch loop.

Common situations: Database credential/config changes mid-run, network partition to mongo/redis, unhandled exceptions in the resync loop, manual kill causing state races.

Related errors


AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03). Data as JSON: /api/errors/652b58e5d6edda17. Report an issue: GitHub.