Refuse a Gaia answer that came back short, and read the body inside the retry
The merge gate asks whether Gaia contributed any stars, never how many. The TAP service truncates on its own timeout and still serves a well-formed CSV with a 200, ordered by magnitude — so a half answer is the bright half, which is the half HYG overlaps. Every gate passes: Gaia stars are present, HYG survivors go down rather than up, unmerged twins can only fall. The weekly job would publish a catalogue missing two hundred thousand stars and the runner would cache it for the weeks after. `fetchGaiaStars` now refuses fewer than 95% of the 412 765 rows its query holds, as its sibling query already did, and refuses an answer that fills the row limit. `fetchText` retried the request but not the body: a connection reset part-way through the 57 MB CSV rejected out of the loop, with no wait and no second attempt. The read now happens inside it. Also corrected: the merge gate's account of the HYG survivors (two thirds of them are stars Gaia measures but the main query never downloads, since Gaia puts them past the 250 pc cutoff), and the refresh workflow's comment on what happens when the archive is unreachable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016jxMkwA2rbicdGxHosecYi
This commit is contained in:
@@ -34,9 +34,15 @@ const RETRY_DELAYS_MS = [30_000, 120_000];
|
||||
|
||||
async function fetchText(url: string): Promise<string> {
|
||||
for (let attempt = 0; ; attempt++) {
|
||||
const response = await fetch(url).catch((error: unknown) => (error instanceof Error ? error : new Error(String(error))));
|
||||
let response = await fetch(url).catch((error: unknown) => (error instanceof Error ? error : new Error(String(error))));
|
||||
if (!(response instanceof Error) && response.ok) {
|
||||
return response.text();
|
||||
// Read inside the loop, because the body is where these downloads fail: the Gaia CSV is
|
||||
// 57 MB, and a connection reset part-way through rejects here, long after the 200.
|
||||
const body = await response.text().catch((error: unknown) => (error instanceof Error ? error : new Error(String(error))));
|
||||
if (typeof body === 'string') {
|
||||
return body;
|
||||
}
|
||||
response = body;
|
||||
}
|
||||
const reason = response instanceof Error ? response.message : `${response.status} ${response.statusText}`;
|
||||
// A 4xx is the request's own fault, and waiting will not change the answer.
|
||||
|
||||
Reference in New Issue
Block a user