Skip to content

fix(aviation): replace broken lock with direct cache + cancellation tiers#591

Merged
koala73 merged 1 commit intomainfrom
fix/aviation-stack-lock-race
Feb 28, 2026
Merged

fix(aviation): replace broken lock with direct cache + cancellation tiers#591
koala73 merged 1 commit intomainfrom
fix/aviation-stack-lock-race

Conversation

@koala73
Copy link
Owner

@koala73 koala73 commented Feb 28, 2026

Summary

  • Root cause: Redis SETNX lock waited 3s but AviationStack takes ~25s for 50 airports → every lock-loser fell back to simulation → real API data was never served
  • Fix: Replace fetchIntlWithLock/tryAcquireLock with direct getCachedJson/setCachedJson and conditional TTL (30min real, 5min simulation)
  • Cancellation tiers: DXB at 32% cancelled was silently dropped (null). Added ≥20% → moderate, ≥10% → minor thresholds
  • NOTAM defense: ICAO CloudFront returns HTML challenge pages from Vercel IPs — added content-type check before JSON parse

Verified with live API

AUH: 100 flights, 92 cancelled → severe closure ✓
DXB: 100 flights, 32 cancelled → moderate ✓ (was null before)
DOH: 100 flights, 2 cancelled  → no alert ✓ (correct)
NOTAM: returns valid JSON locally, HTML from Vercel IPs (handled gracefully)

Test plan

  • npx tsc --noEmit passes
  • Deploy → check Vercel logs for [Aviation] AviationStack OK: instead of falling back to simulation
  • AUH should show severe closure alert in aviation panel
  • DXB should show moderate delay (32% cancelled) instead of simulated data
  • NOTAM errors should log clean warning, not JSON parse crash

Supersedes #589

…ancellation tiers

The Redis SETNX lock for AviationStack had a 3s wait but the API takes
~25s for 50 airports. Every lock-loser fell back to simulation — meaning
AviationStack data was never served despite the API key being configured.

Changes:
- Remove fetchIntlWithLock/tryAcquireLock, use getCachedJson/setCachedJson
  with conditional TTL (30min real data, 5min simulation fallback)
- Add cancellation severity tiers: ≥20% moderate, ≥10% minor (DXB at 32%
  cancelled was previously dropped as null)
- Bump cache key to v2 to invalidate stale simulation data
- Add HTML content-type detection for NOTAM API (ICAO CloudFront returns
  HTML challenge pages from Vercel datacenter IPs)
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel
Copy link

vercel bot commented Feb 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Building Building Preview, Comment Feb 28, 2026 8:38pm
worldmonitor-finance Building Building Preview, Comment Feb 28, 2026 8:38pm
worldmonitor-happy Building Building Preview, Comment Feb 28, 2026 8:38pm
worldmonitor-startup Building Building Preview, Comment Feb 28, 2026 8:38pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant