Skip to content

Open source alternative to Semrush and Ahrefs

Fix site audit results running out of memory on large audits (#877)

Ben Senescu4b8b4aa0ea58
diff --git a/src/db/audit.schema.ts b/src/db/audit.schema.ts
index c9b49bc6..8d30de37 100644
--- a/src/db/audit.schema.ts
+++ b/src/db/audit.schema.ts
@@ -83,6 +83,8 @@ export const auditPages = sqliteTable(
h4Count: integer("h4_count").notNull().default(0),
h5Count: integer("h5_count").notNull().default(0),
h6Count: integer("h6_count").notNull().default(0),
+ // No longer written; existing rows still hold data. Drop with images_json
+ // and hreflang_tags_json once no deployed code references them.
headingOrderJson: text("heading_order_json"),
// Content
wordCount: integer("word_count").notNull().default(0),
diff --git a/src/db/pg/audit.schema.ts b/src/db/pg/audit.schema.ts
index 8bec00d5..5fbeb4fd 100644
--- a/src/db/pg/audit.schema.ts
+++ b/src/db/pg/audit.schema.ts
@@ -88,6 +88,8 @@ export const auditPages = pgTable(
h4Count: integer("h4_count").notNull().default(0),
h5Count: integer("h5_count").notNull().default(0),
h6Count: integer("h6_count").notNull().default(0),
+ // No longer written; existing rows still hold data. Drop with images_json
+ // and hreflang_tags_json once no deployed code references them.
headingOrderJson: text("heading_order_json"),
// Content
wordCount: integer("word_count").notNull().default(0),
diff --git a/src/server/features/audit/repositories/AuditRepository.ts b/src/server/features/audit/repositories/AuditRepository.ts
index a90923d7..37ededae 100644
--- a/src/server/features/audit/repositories/AuditRepository.ts
+++ b/src/server/features/audit/repositories/AuditRepository.ts
@@ -176,16 +176,13 @@ async function insertCrawledBatch(
h4Count: page.h4Count,
h5Count: page.h5Count,
h6Count: page.h6Count,
- headingOrderJson: JSON.stringify(page.headingOrder),
wordCount: page.wordCount,
contentHash: page.contentHash,
imagesTotal: page.imagesTotal,
imagesMissingAlt: page.imagesMissingAlt,
- imagesJson: JSON.stringify(page.images),
internalLinkCount: page.links.filter((l) => l.isInternal).length,
externalLinkCount: page.links.filter((l) => !l.isInternal).length,
hasStructuredData: page.hasStructuredData,
- hreflangTagsJson: JSON.stringify(page.hreflangTags),
isIndexable: page.isIndexable,
fetchClass: page.fetchClass,
crawlDepth: page.crawlDepth,
@@ -355,6 +352,14 @@ async function getAuditResultsForProject(auditId: string, projectId: string) {
const [pages, lighthouse, issues] = await Promise.all([
db.query.auditPages.findMany({
where: eq(auditPages.auditId, auditId),
+ // The results UI never reads these per-page JSON blobs, and on a
+ // 10k-page audit images alone run to ~12 MB — enough to push this
+ // request past the Worker's 128 MB memory limit.
+ columns: {
+ imagesJson: false,
+ headingOrderJson: false,
+ hreflangTagsJson: false,
+ },
}),
db.query.auditLighthouseResults.findMany({
where: eq(auditLighthouseResults.auditId, auditId),