Skip to content

HELD: multiple events draws the first map at once; /api/events only brings the names - #10

Draft
pietechsolution wants to merge 1 commit into
mainfrom
perf/map-before-event-names
Draft

pietechsolution wants to merge 1 commit into
mainfrom
perf/map-before-event-names

Conversation

@pietechsolution

Copy link
Copy Markdown
Contributor

HELD. Demo speed: the multiple events page stops waiting on /api/events before drawing its map.

Why

The live demo at seatlayer.io/demo/sdk/multiple-events regressed from 1.5 s to 2.5–2.7 s cold (headless Chromium, BLR, 2026-09-29). The SeatLayer API was not the cause: GET /v1/events/:key p50 fell from 356 to 264 ms. The switcher mounted no map until GET /api/events answered, and that route (one server-SDK read per event) takes 370–940 ms from India, measured with curl ×6. Bootstrap only starts after it.

What

The event keys are public build-time config. The list with its placeholder names moves to lib/config.ts (configuredEvents), and the route reads the same list.

  • The switcher starts from configuredEvents and selects the first event at once, so the map loads immediately.
  • When /api/events answers, the names are replaced in place. The open map (same key, same position) and any hold on it stay; nothing reloads.
  • If the route fails, the placeholder names stay and every map still works. The old "The event list could not be loaded." error no longer blocks the page.

Why not an edge cache

An edge cache would only hide the route's latency on a hit, and would need Cloudflare-specific cache code in a public example. The map never needed the names, so removing the dependency is simpler, and nothing can go stale.

Secret safety

Unchanged. SEATLAYER_SECRET_KEY is still read only inside the route handler. The response still carries only { key, name } and a source label. No new cache, header or log line.

Measured (local next start, live demo public keys, prod API; /api/events made slow by a refused test key, ~615 ms)

bootstrap starts at map drawn
before (main) 574–783 ms (after /api/events answers, then the chart chunk loads) 1,055–1,300 ms
after 271–307 ms (while /api/events is still pending) 769–1,275 ms

The "after" on prod gets measured once the demo Worker is redeployed from main.

Checks

  • npx tsc --noEmit OK.
  • next build OK (the /multiple-events page is 1.98 kB).
  • Local run above.

Edge case

With only one event key configured and a secret key set, the page now shows three tabs with the same real name. Before, the route's deduplicated list showed one. The live demo configures three distinct keys, so it's unaffected.

…e names

The event keys are public config, but the switcher mounted no map until
/api/events answered. On the live demo that route (a server-SDK read per
event) took 370-940 ms, so the seat map's bootstrap waited behind it.

The switcher now starts from the configured events with their placeholder
names and selects the first one straight away. When the route answers, the
names are replaced in place, so the open map and any hold on it stay. If the
route fails, the placeholder names stay and every map still works.
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.

2 participants