Skip to content

Commit 23086e8

Browse files
committed
fix accidentally swallowing errors for non back fill scraper runs
1 parent 46b4463 commit 23086e8

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

functions/src/scraper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import { currentGeneralCourt } from "./shared"
88
type Batch = {
99
court: number
1010
ids: string[]
11+
/** When true, unexpected (non-Axios) errors are logged and the batch
12+
* continues with the next id instead of failing the whole invocation.
13+
* Used by the per-court backfill script so one bad id doesn't sink a
14+
* historical-court run. Defaults to false for the scheduled prod path. */
15+
resilient?: boolean
1116
}
1217

1318
/** List all ids of the resources to scrape. Falsey values will be filtered out.
@@ -146,8 +151,10 @@ export function createScraper<T>({
146151
`Could not fetch resource ${resourceName}/${id}: ${e.message}`
147152
)
148153
}
149-
} else {
154+
} else if (batch.resilient) {
150155
logger.error(`Unexpected error fetching ${resourceName}/${id}`, e)
156+
} else {
157+
throw e
151158
}
152159
}
153160
}

scripts/firebase-admin/runScrapersByCourt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async function processQueue(
123123
// otherwise fetchBatch could finish and delete the doc before we record it.
124124
const ref = batches.doc()
125125
ours.add(ref.id)
126-
await ref.set({ court, ids })
126+
await ref.set({ court, ids, resilient: true })
127127
}
128128

129129
return new Promise<void>((resolve, reject) => {

0 commit comments

Comments
 (0)