feat(cubejs/smart-gen): pre-warm compiler cache after save#55
Merged
Conversation
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>
firsi
approved these changes
May 10, 2026
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.
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
🤖 Generated with Claude Code