Skip to content

fix(deploy): set STATIC_URL for the production frontend build - #411

Merged
field123 merged 1 commit into
masterfrom
fix/frontend-deploy-static-url
Aug 11, 2026
Merged

fix(deploy): set STATIC_URL for the production frontend build#411
field123 merged 1 commit into
masterfrom
fix/frontend-deploy-static-url

Conversation

@field123

Copy link
Copy Markdown
Collaborator

Fixes the integration outageUnexpected fields on [CodeComponentMeta]: + subtreePrefetchingConfig when opening an existing project.

What happened

deploy-integration succeeded on 00af6c2976; deploy-frontend — which runs on workflow_run after it — failed (run 31478165556):

error   process.env.STATIC_URL missing in production build
    at tools/webpack/mkDefinePluginOptsForEnv.ts:49
    at rsbuild.config.ts:245

STATIC_URL arrived with the upstream merge (it has zero hits in the pre-merge mkDefinePluginOptsForEnv.ts) and is declared OPTIONAL_VAR at rsbuild.config.ts:248. OPTIONAL_VAR is fatal when NODE_ENV=production, so the build died before emitting anything and the S3 bundle was never replaced.

Why that produced the error

The two halves of the deploy diverged:

  • Server (new): reads a project, runs migration 258-add-code-component-subtree-prefetching-config, writes subtreePrefetchingConfig onto every CodeComponentMeta.
  • Studio client (stale, pre-merge): its compiled classes-metas has no such field.

model-meta.ts:288-295 prefixes + for a key present on the instance but absent from the meta — precisely this direction. So it's a client/server skew, not corrupt data and not a bad migration.

The fix

NODE_ENV=production PUBLIC_URL=${FRONTEND_URL} STATIC_URL=${FRONTEND_URL} yarn build

getStaticUrl() is process.env.STATIC_URL || getPublicUrl() (shared/urls.ts:63), so FRONTEND_URL reproduces pre-merge behaviour exactly. Deliberately not HOST_URL — upstream #3049 (DEVOP-445) moves static/canvas content to a dedicated subdomain, and repointing where Studio fetches static assets is a behaviour change that shouldn't ride along with an incident fix. Worth doing deliberately afterwards.

After merging

Dispatch deploy-frontend.yml with environment=integration, then confirm an existing project opens. No data repair needed — the bundles are correct; only the client was behind.

Follow-ups

  • Prod promotion must not go out until this has landed, or prod gets the same skew.
  • deploy-frontend failing leaves a silently half-deployed system: the server moves, the client doesn't, and nothing blocks or alerts. Worth making a frontend-deploy failure a hard gate.

The upstream merge (#313) added STATIC_URL to rsbuild.config.ts as
OPTIONAL_VAR. mkDefinePluginOptsForEnv treats an unset OPTIONAL_VAR as fatal
when NODE_ENV=production, so the integration frontend build died with
"process.env.STATIC_URL missing in production build" and the S3 bundle was
never replaced.

That left Studio serving pre-merge client JS against a post-merge server. The
server migrates bundles and writes CodeComponentMeta.subtreePrefetchingConfig
(migration 258); the stale client's compiled model meta has no such field, so
opening any existing project failed with:

  Unexpected fields on [CodeComponentMeta]: + subtreePrefetchingConfig

getStaticUrl() falls back to getPublicUrl() (shared/urls.ts:63), so setting
STATIC_URL to FRONTEND_URL reproduces pre-merge behaviour exactly and keeps
static assets on our own CloudFront distribution rather than moving them.
@field123
field123 force-pushed the fix/frontend-deploy-static-url branch from d0be1a1 to 9ec5c7c Compare August 11, 2026 15:50
@field123
field123 merged commit 5e6c80c into master Aug 11, 2026
5 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.

1 participant