worldmonitor icon indicating copy to clipboard operation
worldmonitor copied to clipboard

fix(tech-events): cache the widest payload on cold-start fallback (#5427)

Open lspassos1 opened this issue 4 months ago • 1 comments

Summary

Closes #5427.

research:tech-events:v1 is a shared, request-independent Redis key — the Railway relay seeds the full event list under it every 6h, and listTechEvents() narrows per caller afterwards via filterEvents(). The cold-start fallback fetcher broke that contract: it forwarded the live request's type/mappable/limit/days into fetchTechEvents() and cached that narrowed payload under the shared key. Whichever request warmed a cold cache decided what every client saw for the next 6 hours (?type=conference&limit=5 pinned 5 events; even a parameterless request pinned the 50/90 defaults, capping later ?limit=200&days=365 callers below the documented maxima).

Fix: the fallback now fetches with an exported WIDEST_TECH_EVENTS_REQUEST (type: 'all', mappable: false, and the clamp maxima limit: 200, days: 365, passed with explicit presence so they resolve as-is). Per-request narrowing already happens in filterEvents() on the read path — it re-applies every filter and recomputes count/conferenceCount/mappableCount from the narrowed set — so responses on the seeded path are byte-for-byte unchanged; only the cached payload's width changes, matching what the seeder writes.

Type of change

  • [x] Bug fix

Affected areas

  • [x] API endpoints (/api/*)

Checklist

  • [ ] Tested on worldmonitor.app variant
  • [ ] Tested on tech.worldmonitor.app variant (if applicable)
  • [ ] New RSS feed domains added to api/rss-proxy.js allowlist (if adding feeds)
  • [x] No API keys or secrets committed
  • [x] TypeScript compiles without errors (npm run typecheck)

Documentation Alignment Checklist

N/A — no documented API contract changes: request/response schemas and per-request filter semantics are untouched; only the internally cached payload widens to the seeder's shape.

Verification

  • New tests/tech-events-cold-start-widest.test.mts pins the widest-request contract: no type/mappable narrowing, resolves exactly to the clamp maxima (200/365), and can never resolve narrower than a maxed-out explicit request.
  • tech-events-paging, shared-relay, relay-boot-seed-freshness-guard, and openapi-filter-param-schemas suites: 84 tests green.
  • npm run typecheck clean.

Screenshots

N/A — server-side caching behavior.

lspassos1 avatar Jul 25 '26 19:07 lspassos1

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

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment Jul 29, 2026 4:05pm

Request Review

vercel[bot] avatar Jul 25 '26 19:07 vercel[bot]

Greptile Summary

The PR corrects cold-start population of the shared tech-events cache.

  • Adds a fixed widest request using the documented paging maxima.
  • Uses that request for cache-miss fetching before applying caller-specific filters on reads.
  • Adds unit coverage for the widest-request values and paging resolution.

Confidence Score: 4/5

The implementation appears safe to merge, with a non-blocking gap in regression coverage for the production fallback wiring.

The fixed request is a superset of every supported caller request and the read path reapplies equivalent filters, but the new test would not detect removal or alteration of the actual fallback call.

Files Needing Attention: tests/tech-events-cold-start-widest.test.mts

Important Files Changed

Filename Overview
server/worldmonitor/research/v1/list-tech-events.ts Correctly replaces request-dependent cold-cache population with the widest supported fetch while retaining per-request read filtering.
tests/tech-events-cold-start-widest.test.mts Verifies the widest constant and paging bounds but does not cover its wiring into the actual cache-miss callback.

Sequence Diagram

sequenceDiagram
  participant C as Client
  participant H as listTechEvents
  participant R as Redis
  participant U as Upstream feeds
  C->>H: Request with caller filters
  H->>R: Read shared tech-events key
  alt Cache hit
    R-->>H: Shared wide payload
  else Cold cache
    H->>U: Fetch widest request
    U-->>H: Up to 200 events / 365 days
    H->>R: Cache shared wide payload
  end
  H->>H: Geocode and apply caller filters
  H-->>C: Narrowed response and recomputed counts

Reviews (1): Last reviewed commit: "fix(tech-events): cache the widest paylo..." | Re-trigger Greptile

greptile-apps avatar Jul 29 '26 14:07 greptile-apps