abhigyanpatwari/GitNexus · error

[spring-destinations] failed to clear the messaging overlay

Error message

[spring-destinations] failed to clear the messaging overlay before incremental re-write (${message}) — aborting rather than leaving duplicate or orphaned destinations; the next run will full-rebuild

What it means

During deleteAllDestinations, if clearing the Spring messaging overlay (Destination nodes) fails with anything other than a benign 'missing table' error, the adapter wraps the underlying message in this error and aborts. Aborting is deliberate: proceeding with an incremental re-write on a partially cleared overlay would leave duplicate or orphaned destinations; the next run will do a full rebuild instead.

Source

Thrown at gitnexus/src/core/lbug/lbug-adapter.ts:3215

  return withConnLock(async () => {
    let countResult: lbug.QueryResult | lbug.QueryResult[] | undefined;
    try {
      countResult = await c.query('MATCH (n:Destination) RETURN count(n) AS cnt');
      const result = Array.isArray(countResult) ? countResult[0] : countResult;
      const rows = await result.getAll();
      const count = Number(rows[0]?.cnt ?? rows[0]?.[0] ?? 0);
      if (count > 0) {
        await closeQueryResults(await c.query('MATCH (n:Destination) DETACH DELETE n'));
      }
      if (countResult) await closeQueryResults(countResult);
      return { nodesDeleted: count };
    } catch (err) {
      if (countResult) await closeQueryResults(countResult);
      if (classifyDeleteAllError(err) === 'benign-missing-table') {
        return { nodesDeleted: 0 };
      }
      const message = err instanceof Error ? err.message : String(err);
      throw new Error(
        '[spring-destinations] failed to clear the messaging overlay before incremental ' +
          `re-write (${message}) — aborting rather than leaving duplicate or orphaned ` +
          'destinations; the next run will full-rebuild',
      );
    }
  });
};

/**
 * Drop Spring-owned auto-configuration `DECLARES` relationships before
 * incremental writeback. `DECLARES` is generic, so exact reason filtering is
 * required: other metadata systems must retain their own declarations.
 */
export const deleteSpringAutoConfigurationDeclarations = async (): Promise<{
  edgesDeleted: number;
}> =>
  deleteAllRelationshipsOfType(
    'DECLARES',

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Read the inner (${message}) cause to identify the real failure (lock, query error, IO) and fix that.
  2. Ensure no other process holds the LadybugDB lock (close other gitnexus serve/index runs) and retry.
  3. If the overlay is suspect, force a full rebuild of the index instead of an incremental run — the error already guarantees the next run will full-rebuild.
  4. Restore or delete the corrupted database file if the underlying error indicates corruption.

Example fix

// before: treating the wrapper error generically
catch (e) { logger.error(e.message); }

// after: unwrap and act on the cause
try {
  await deleteAllDestinations();
} catch (e) {
  const cause = e.message.match(/\((.*)\)/)?.[1] ?? String(e);
  logger.error('overlay clear failed, scheduling full rebuild:', cause);
  await runFullRebuild();
}
Defensive patterns

Strategy: retry

Try / catch

try {
  await deleteAllDestinations();
} catch (err) {
  const cause = err instanceof Error ? err.message : String(err);
  if (cause.includes('failed to clear the messaging overlay')) {
    logger.error('scheduling full rebuild; cause:', cause);
    await scheduleFullRebuild();
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: The count or MATCH/DELETE queries inside deleteAllDestinations throw (database locked, query failed, connection dropped) and classifyDeleteAllError(err) !== 'benign-missing-table'.

Common situations: LadybugDB file locked by another process during incremental indexing; transient DB I/O error mid-delete; schema change so Destination table exists but queries fail for another reason.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-09-08). Data as JSON: /api/errors/bb427decb10e7f20. Report an issue: GitHub.