Skip to content

feat(cubejs/smart-gen): pre-warm compiler cache after save#55

Merged
acmeguy merged 1 commit into
mainfrom
feat/cubejs-prewarm-after-save
May 10, 2026
Merged

feat(cubejs/smart-gen): pre-warm compiler cache after save#55
acmeguy merged 1 commit into
mainfrom
feat/cubejs-prewarm-after-save

Conversation

@acmeguy
Copy link
Copy Markdown

@acmeguy acmeguy commented May 10, 2026

Why

The editor refetches `metaConfig` immediately after a save to refresh the field tree. Without warm-up, that refetch is the first request to see the new `content_version`, so it hits a cold compile (15-30s on real schemas) and Hasura's webhook timeout fires before the response. The user sees "save timed out" even though the version row is already in the database.

Companion to #54 (which raises the action timeout from 30s → 120s as a safety belt). With both shipped, the user-visible latency on save is bounded by the response of the already-running background compile, not a fresh cold-compile.

What

In `services/cubejs/src/routes/smartGenerate.js`, after `createDataSchema` + `compilerCache.purgeStale()`, fire-and-forget a `compilerApi.metaConfig()` call for the new context. Save response returns immediately; next user-facing fetch hits a warm cache.

Errors swallowed: failed pre-warm falls back to the previous behavior of compiling on first user fetch. No correctness change, only latency.

Test plan

  • Save a cube on dbx.fraios.dev with the feat(datasources): Materialize synmetrix/synmetrix#54 action-timeout fix already deployed
  • Watch `kubectl logs -n synmetrix synmetrix-cubejs-* -f` — see the `prewarm-` request follow each save
  • Network tab in editor: `fetch_meta` after a save returns in <1s (warm) instead of 15-30s (cold)
  • If pre-warm fails (e.g. context ctor errors), confirm warning logged and save still succeeds

🤖 Generated with Claude Code

The editor refetches metaConfig immediately after a save to refresh the
field tree. Without warm-up, that refetch is the first request to see
the new content_version, so it hits a cold compile (15-30s on real
schemas) and Hasura's webhook timeout fires before the response. The
user sees "save timed out" even though the version row is already in
the database.

Fire-and-forget: after createDataSchema + compilerCache.purgeStale(),
kick off compilerApi.metaConfig() for the new context. We don't await
the result — the save response returns immediately, but the next user-
facing fetch hits a warm cache.

Errors are logged and swallowed: a failed pre-warm just falls back to
the previous behavior of compiling on first user fetch. Doesn't change
correctness, only latency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@acmeguy acmeguy merged commit 5405b9e into main May 10, 2026
3 checks passed
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