fix(conflicts): /api/conflicts times out and returns no data - #219
Open
BenJule wants to merge 1 commit into
Open
fix(conflicts): /api/conflicts times out and returns no data#219BenJule wants to merge 1 commit into
BenJule wants to merge 1 commit into
Conversation
The conflicts feed ran three GDELT queries sequentially, each spaced 6s apart (GDELT allows ~1 query/5s), plus an extra 6s delay before the per-query DOC fallback. Worst case that is ~90s, which exceeds the client/proxy timeout, so /api/conflicts returned nothing at all (the layer was always empty). Use a single combined query and cut the DOC-fallback spacing to 1.5s, so the route completes in ~10-15s and actually returns conflict events.
|
@BenJule is attempting to deploy a commit to the Amanda's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/conflictsreturns nothing — the conflict layer is always empty.The route fetches from GDELT with three queries run sequentially, each spaced 6s apart (GDELT rate-limits to ~1 query/5s), plus an extra 6s delay before the per-query DOC-API fallback. In the worst case that's roughly 90s, which is well past the client/proxy timeout, so the endpoint times out and the frontend gets no data at all.
Fix
airstrike OR missile OR shelling OR bombing OR frontline OR drone strike OR war casualties).The route now completes in ~10–15s and actually returns conflict events. Coverage is comparable since GDELT scores the same corpus regardless of how the OR-terms are split.
Test
Built and deployed;
GET /api/conflictswent from a hard timeout (no response) to200with populatedzones/events in ~14s. (I run this behind a short nginx cache so repeat loads are instant.)Note (separate issue)
/api/air-qualityis also empty because it calls the deprecated OpenAQ v2 API (/v2/latest). v2 has been sunset; v3 needs an API key and a different response shape. Happy to send a follow-up PR for that if you'd like the v3 migration.