Description:

When the Vite manifest file cannot be loaded (ManifestNotFoundException or ManifestCouldNotBeLoadedException), `AssetLibrary::getViteManifest()` calls `$this->messenger->addError()` at line 83 of `src/AssetLibrary.php`.

This triggers Drupal's `page_cache_kill_switch` service (via `Messenger::addMessage()` which calls `$this->killSwitch->trigger()`), which sets the response to `Cache-Control: must-revalidate, no-cache, private` and marks the page as `UNCACHEABLE (response policy)`. This prevents caching by both Drupal's internal page cache and any reverse proxy (Varnish, CDN).

The error is already being logged via `$this->logger->error()` on the very next line (line 84), so the messenger call is redundant for debugging purposes. The messenger error is also problematic because it surfaces an internal infrastructure error to end users, which is not useful on a production site.

Steps to reproduce:

1. Enable the vite module with a theme that uses Vite
2. Temporarily rename or delete the manifest.json file
3. Visit any page on the site
4. Check the response headers — you'll see `Cache-Control: must-revalidate, no-cache, private` and `X-Drupal-Cache: UNCACHEABLE (response policy)`
5. Restore the manifest file and visit the page again — caching works normally

Proposed fix:

Remove the `$this->messenger->addError()` call in `AssetLibrary::getViteManifest()`. The `$this->logger->error()` call on the next line already records the error for debugging. If a user-facing message is needed, it should only be shown to administrators and should not trigger the page cache kill switch.

Issue fork vite-3584026

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ethant created an issue. See original summary.

wotnak made their first commit to this issue’s fork.

  • wotnak committed 12de0c93 on 1.x authored by ethant
    fix: #3584026 Avoid triggering the page cache kill switch in...
wotnak’s picture

Status: Needs review » Fixed

Merged and released in 1.5.3.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.