Frontend service serves stale build artifacts — snapshot not updating after pushes
lukasashic
HOBBYOP

15 days ago

My frontend service (endearing-adaptation) is serving stale build

artifacts despite multiple successful deployments.

Problem:

  • Production serves old chunk hash BlogPostIndex-Dxh2gH40.js
  • Local build produces BlogPostIndex-D7r3gRXj.js
  • All deployments show "Deployment successful" but old index.html is served
  • Railway snapshot is always exactly 21.1 MB regardless of source changes

What I tried:

  • CACHE_BUST environment variable
  • Disabled "Skipped Builds" feature flag
  • Switched to Dockerfile builder (multi-stage, rm -rf dist)
  • Disconnected and reconnected GitHub repo
  • Multiple manual redeploys and restarts
  • Trivial source file changes to force cache invalidation

What IS working:

  • Initial blog deploy (commit 976fe5a) deployed correctly
  • Backend service deploys correctly on every push
  • Build logs show "✓ built in 5.17s" but served index.html is stale

Repo: LukaSashic/BusinessFlow

Service: endearing-adaptation

Root Directory: /frontend

$10 Bounty

3 Replies

Status changed to Open Railway 15 days ago


ve-jo
HOBBYTop 5% Contributor

15 days ago

I'll try to help. The two most common causes here could be are:

  1. Vite builds the new hash into dist, but the runtime image is serving a different directory.
  2. The Dockerfile/root directory/build context is not the one you think it is, so its builds successfully but could be an old or wrong artifact into the final image.

The snapshot size staying exactly 21.1 MB is suspicious, but not conclusive by itself. Just check if its correct.


Also try accessing the site from an incognito window.


sheeki03
FREE

15 days ago

I would separate this into two checks: whether Railway is building the expected source, and whether the final container is serving the expected build output.

The strongest signal in your report is that the served index.html still points at BlogPostIndex-Dxh2gH40.js while a local build produces BlogPostIndex-D7r3gRXj.js. If the build log says Vite built successfully but the public app still serves the old chunk, either the final runtime image did not receive the new dist, or the service is not running the image built from the commit you think it is.

I would add a temporary build marker to the frontend build and make it publicly readable:

ARG RAILWAY_GIT_COMMIT_SHA
RUN npm run build \
  && echo "$RAILWAY_GIT_COMMIT_SHA" > dist/__railway_build.txt \
  && grep -R "BlogPostIndex-" dist/index.html \
  && find dist/assets -maxdepth 1 -type f -name "BlogPostIndex-*.js" -print

Then redeploy and check:

curl -s https://YOUR_DOMAIN/__railway_build.txt
curl -s https://YOUR_DOMAIN/index.html | grep -o 'BlogPostIndex-[^"]*\\.js'

If the build log prints BlogPostIndex-D7r3gRXj.js but the public index.html still returns BlogPostIndex-Dxh2gH40.js, the problem is after the Vite build. In that case, check the Dockerfile final stage carefully. For an nginx/static image, the final copy should point at the exact Vite output directory from the builder stage, for example:

COPY --from=builder /app/dist /usr/share/nginx/html

or, if the builder is not already inside /frontend:

COPY --from=builder /app/frontend/dist /usr/share/nginx/html

Also make sure the service source settings line up:

  • Root Directory should be /frontend.
  • The Dockerfile being used should be the frontend Dockerfile, not a root-level or backend Dockerfile.
  • Watch paths, if configured, should include /frontend/**.
  • The deployment details should show the commit SHA that contains the new chunk.

One practical way to force a clean source/context boundary for this service is to deploy the frontend directory as the root context:

railway up --service endearing-adaptation --path-as-root frontend

If that immediately serves the new chunk, the issue is not Vite caching. It means the Git-based service build is receiving or selecting the wrong source context, Dockerfile, or final artifact path. At that point the useful escalation packet for Railway is:

  1. Deployment ID.
  2. Git commit SHA shown in Railway.
  3. Build log line from grep -R "BlogPostIndex-" dist/index.html.
  4. Public curl output for /index.html.
  5. Public curl output for /__railway_build.txt.

That will show exactly whether the stale artifact is introduced during source selection, image build, final-stage copy, or runtime serving.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...