earendil-works/pi · error · SessionError

storage

storage

Error message

Failed to build SQLite branch cache at entry ${leafId}

What it means

Error "Failed to build SQLite branch cache at entry ${leafId}" thrown in earendil-works/pi.

Source

Thrown at packages/session-backends/sqlite-node/src/sqlite/branch-cache.ts:46

	for (const tip of tips) buildCachedBranch(db, sessionId, tip.id);
}

export function buildCachedBranch(db: SqliteDatabase, sessionId: string, leafId: string) {
	sql`SAVEPOINT build_branch_cache`.exec(db);
	try {
		const branchId = uuidv7();
		insertBranchEntriesForPath(db, sessionId, branchId, leafId);
		insertBranchTip(db, sessionId, leafId, branchId);
		sql`RELEASE SAVEPOINT build_branch_cache`.exec(db);
	} catch (error) {
		try {
			sql`ROLLBACK TO SAVEPOINT build_branch_cache`.exec(db);
			sql`RELEASE SAVEPOINT build_branch_cache`.exec(db);
		} catch {
			// Preserve the original build failure.
		}
		if (error instanceof SessionError) throw error;
		throw new SessionError(
			"storage",
			`Failed to build SQLite branch cache at entry ${leafId}`,
			error instanceof Error ? error : undefined,
		);
	}
}

function extendBranch(
	db: SqliteDatabase,
	sessionId: string,
	branchId: string,
	parentId: string,
	entryId: string,
	entrySeq: number,
	entryType: string,
	customType: string | null,
) {
	insertBranchEntry(db, sessionId, branchId, entryId, entrySeq, entryType, customType);

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. The branch cache rebuild failed at the reported entry; check database integrity around that leaf.

When it happens

Trigger: Thrown at packages/session-backends/sqlite-node/src/sqlite/branch-cache.ts:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/930ab3eb5da033c5. Report an issue: GitHub.