ASSET_LOAD
An asset request failed on the network or with an HTTP error, so its lease rejected and nothing was cached.
On this page
ASSET_LOAD: cannot load {url}Why it happens
- An image, loaded for the
imageortexturetype in a detachedImage, firederror: a 404, a wrong path, a network error, or a CORS refusal whencrossOriginis set. - A fetched type such as
gltf,ktx2,jsonorbuffergot an HTTP error. The message then holds the status, such as404 /models/lamp.glb. fetchitself failed: the network is down, or a Content Security Policy or CORS refused the request. The message then readscannot fetch {url}.- The URL does not parse:
{url} is not a URL. - There is no DOM, as in server rendering. Every load then fails with
no DOM to load in, without a report.
The error is reported through app.report() with the target asset:<url>, once per attempt. The lease’s ready rejects and its status becomes failed. When the last lease of a failed asset goes, the asset leaves the cache, so the next load is a new attempt.
A preload does not report a failed file, since the page loads it itself. In development it prints a warning that starts with preload of.
How to fix
- Open the URL from the message in the browser and check the status in the network panel.
- Fix the path. A relative URL resolves against
document.baseURI, or against thebaseoption ofapp.assets.preload(). - For files on another origin, make the server send
Access-Control-Allow-Origin. Fetched types always request in CORS mode, and images needcrossOrigin: 'anonymous'in the load options.
import type { App } from '@dioramajs/diorama'
export function cover(app: App) { return app.assets?.load('https://cdn.example.com/cover.avif', { type: 'texture', crossOrigin: 'anonymous', })}