Skip to content

Commit 7e4d07c

Browse files
heiskrCopilot
andauthored
Fix Elasticsearch indexing flakiness by reducing concurrency (#57998)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 11d69f3 commit 7e4d07c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/search/scripts/scrape/lib/build-records.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ dotenv.config()
3737
// These defaults are known to work fine in GitHub Actions.
3838
// For local development, you can override these in your local .env file.
3939
// For example:
40-
// echo 'BUILD_RECORDS_MAX_CONCURRENT=20' >> .env
41-
// echo 'BUILD_RECORDS_MIN_TIME=50' >> .env
42-
const MAX_CONCURRENT = parseInt(process.env.BUILD_RECORDS_MAX_CONCURRENT || '100', 10)
43-
const MIN_TIME = parseInt(process.env.BUILD_RECORDS_MIN_TIME || '5', 10)
40+
// echo 'BUILD_RECORDS_MAX_CONCURRENT=5' >> .env
41+
// echo 'BUILD_RECORDS_MIN_TIME=200' >> .env
42+
const MAX_CONCURRENT = parseInt(process.env.BUILD_RECORDS_MAX_CONCURRENT || '5', 10)
43+
const MIN_TIME = parseInt(process.env.BUILD_RECORDS_MIN_TIME || '200', 10)
4444

4545
// These products, forcibly always get a popularity of 0 independent of
4646
// their actual popularity which comes from an external JSON file.

src/search/scripts/scrape/lib/domwaiter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function getPage(page: Permalink, emitter: EventEmitter, opts: DomWaiterOp
6262

6363
if (opts.json) {
6464
try {
65-
const response = await fetchWithRetry(page.url!, undefined, { retries: 3 })
65+
const response = await fetchWithRetry(page.url!, undefined, { retries: 3, timeout: 60000 })
6666
if (!response.ok) {
6767
throw new HTTPError(
6868
`HTTP ${response.status}: ${response.statusText}`,
@@ -74,11 +74,14 @@ async function getPage(page: Permalink, emitter: EventEmitter, opts: DomWaiterOp
7474
const pageCopy = Object.assign({}, page, { json })
7575
emitter.emit('page', pageCopy)
7676
} catch (err) {
77+
if (err instanceof Error) {
78+
err.message = `Failed to fetch ${page.url}: ${err.message}`
79+
}
7780
emitter.emit('error', err)
7881
}
7982
} else {
8083
try {
81-
const response = await fetchWithRetry(page.url!, undefined, { retries: 3 })
84+
const response = await fetchWithRetry(page.url!, undefined, { retries: 3, timeout: 60000 })
8285
if (!response.ok) {
8386
throw new HTTPError(
8487
`HTTP ${response.status}: ${response.statusText}`,
@@ -91,6 +94,9 @@ async function getPage(page: Permalink, emitter: EventEmitter, opts: DomWaiterOp
9194
if (opts.parseDOM) (pageCopy as any).$ = cheerio.load(body)
9295
emitter.emit('page', pageCopy)
9396
} catch (err) {
97+
if (err instanceof Error) {
98+
err.message = `Failed to fetch ${page.url}: ${err.message}`
99+
}
94100
emitter.emit('error', err)
95101
}
96102
}

0 commit comments

Comments
 (0)