Skip to content

fix: keep the site up when a Vite build is missing - #454

Merged
ogorzalka merged 2 commits into
release/v13.35.5from
fix/missing-theme-build
Oct 9, 2026
Merged

ogorzalka merged 2 commits into
release/v13.35.5from
fix/missing-theme-build

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Fixes Pollora/pollora#79.

Problem

When a theme's build is missing (npm absent, build failed, public/build deleted), every request answered 500, wp-login.php and wp-admin included: Vite manifest not found at public/build/theme/default/manifest.json.

Thrown while WordPress boots: init → block registration → BlockRegistrar::registerScriptHandle() → ViteManager::getAssetUrls() → the getAssetUrls Vite macro → Vite::manifest(). The layout's Asset::url() reads the same manifest through ViteManager::asset().

Fix

  • ViteManager::isMissingBuild(): neither a running dev server nor a manifest. Then getAssetUrls() returns ['js' => [], 'css' => []] and asset() an empty string, instead of throwing. Blocks register without scripts, theme assets are left out.
  • MissingBuilds (singleton) records each missing build: one Log::warning per container per request, with the manifest path.
  • MissingBuildNotice on admin_notices (users with manage_options): one line per manifest with the containers using it, npm install && npm run build (ddev npm … under DDEV) and php artisan pollora:doctor, whose builds check names the folder.

Tests

  • Unbuilt container: no URLs, asset() → '', no exception.
  • Recorded once with its manifest path, a single warning logged across several lookups.
  • Nothing recorded for a built container or one served by the dev server.
  • Notice: names the containers and manifest once, and both commands; silent when every build is there.

Checked on a real site

On pollora-debugbar, build hidden (public/build/theme/default renamed):

  • before: /, a page, wp-login.php, wp-admin → 500 Vite manifest not found
  • after: / → 200, wp-login.php → 200 (login form), wp-admin → login redirect; log: Pollora: the "theme" assets are not built, no Vite manifest at …; admin_notices for an admin prints "Pollora: assets not built — theme.blocks, theme — no manifest at public/build/theme/default/manifest.json".
  • build restored: notice gone, pages 200.

Changelog: [Unreleased] → ### Fixed.

Laravel's Vite throws on a missing manifest, and blocks resolve their
scripts while WordPress boots: one unbuilt theme answered 500 on every
request, wp-admin and wp-login.php included. A container with neither a
hot file nor a manifest now gives no asset URLs; the missing build is
logged once per request and named in an admin notice.

Fixes Pollora/pollora#79
@ogorzalka
ogorzalka force-pushed the fix/missing-theme-build branch from 037bf3d to 99f2d7b Compare October 9, 2026 15:39
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