Problem
The timeout increase in #4463 is an immediate mitigation, but the scraper/search integration still has several size-related assumptions that are now brittle with the current corpus size.
Observed production context:
modules_v2 has about 21,096 documents.
moduleInfo bulk indexing is sent as one large request, about 18.5 MB.
ElasticPersist.getModuleCodes() fetches at most 20,000 docs in a single search.
modules_v2 has index.max_result_window = 20000.
- Frontend pagination/random-course paths can request beyond the ES result window and receive HTTP 400.
createIndex() assumes a specific error shape and can throw Cannot read properties of undefined (reading 'type') for other ES errors.
Proposed work
- Chunk scraper
moduleInfo bulk writes by document count and/or byte size.
- Add retry/backoff for transient ES timeout/connection failures.
- Replace
getModuleCodes() single size: 20000 search with scroll/search-after so cleanup sees all existing documents.
- Fix frontend deep pagination/random-course behavior so it does not request beyond
index.max_result_window, or move those paths to a cursor/search-after-safe design.
- Harden ES error handling in
createIndex() and delete paths so unexpected ES/network errors are logged clearly without masking the original cause.
Notes
This is intentionally separate from the timeout mitigation PR so the production scraper can be unblocked first.
Problem
The timeout increase in #4463 is an immediate mitigation, but the scraper/search integration still has several size-related assumptions that are now brittle with the current corpus size.
Observed production context:
modules_v2has about 21,096 documents.moduleInfobulk indexing is sent as one large request, about 18.5 MB.ElasticPersist.getModuleCodes()fetches at most 20,000 docs in a single search.modules_v2hasindex.max_result_window = 20000.createIndex()assumes a specific error shape and can throwCannot read properties of undefined (reading 'type')for other ES errors.Proposed work
moduleInfobulk writes by document count and/or byte size.getModuleCodes()singlesize: 20000search with scroll/search-after so cleanup sees all existing documents.index.max_result_window, or move those paths to a cursor/search-after-safe design.createIndex()and delete paths so unexpected ES/network errors are logged clearly without masking the original cause.Notes
This is intentionally separate from the timeout mitigation PR so the production scraper can be unblocked first.