fix: log fetch error cause in seed retry/FATAL handlers (#1638)

* test: rewrite transit chart test as structural contract verification

Replace fragile source-string extraction + new Function() compilation
with structural pattern checks on the source code. Tests verify:
- render() clears chart before content change
- clearTransitChart() cancels timer, disconnects observer, destroys chart
- MutationObserver setup for DOM readiness detection
- Fallback timer for no-op renders (100-500ms range)
- Both callbacks (observer + timer) clean up each other
- Tab switch and collapse clear chart state
- Mount function guards against missing element/data

Replaces PR #1634's approach which was brittle (method body extraction,
TypeScript cast stripping, sandboxed execution).

* fix: log fetch error cause in seed retry and FATAL handlers

Node 20 fetch() throws TypeError('fetch failed') with the real error
hidden in err.cause (DNS, TLS, timeout). The current logging only shows
'fetch failed' which is useless for diagnosis. Now logs err.cause.message
in both withRetry() retries and FATAL catch blocks.
This commit is contained in:
Elie Habib
2026-03-15 11:09:34 +04:00
committed by GitHub
parent 6b4237dc93
commit 4008f56254
4 changed files with 7 additions and 5 deletions

View File

@@ -144,6 +144,6 @@ runSeed('market', 'etf-flows', CANONICAL_KEY, fetchEtfFlows, {
ttlSeconds: CACHE_TTL,
sourceVersion: 'yahoo-chart-5d',
}).catch((err) => {
console.error('FATAL:', err.message || err);
const _cause = err.cause ? ` (cause: ${err.cause.message || err.cause.code || err.cause})` : ''; console.error('FATAL:', (err.message || err) + _cause);
process.exit(1);
});