EFFECT_SETUP
The setup function of an effect threw or rejected, so that instance failed and its element shows plain DOM.
On this page
EFFECT_SETUP: {message}The message is the message of the error that setup threw, and that error is the cause. Other effects on the same element keep running.
Why it happens
setupthrows, or the promise it returns rejects. An error that is not anEffectErroris wrapped asEFFECT_SETUP. AnEffectErrorthrown inside setup keeps its own code, such asEFFECT_TARGETfromctx.map.- Setup awaits
ctx.texture()orctx.model()and the load fails. The asset error (ASSET_LOAD,ASSET_PARSE) is reported as well, underasset:<url>. ctx.texture()orctx.model()runs in an app without theassetsplugin. The message then reads"{effect}" loads {url}: it needs the assets plugin.start()includesassets, so this happens only withcreateApp.- An async setup reads
ctx.surface,ctx.mapor callsctx.place()after the instance was disposed. The message then readsinstance disposed. Inside an aborted setup this is expected and not reported. - In
@dioramajs/glsl, a texture source orapplyShaderfails (texture {url} failed,applyShader failed), orshaderNodenames a param the effect does not declare.
When setup fails, its scope closes, its surface transforms are removed and the instance becomes failed. The element gets data-dio-state="failed" once every effect on it has failed.
How to fix
- Expand the reported error in the console and read the
cause: its stack points into your setup. - Fix the cause, or catch the failure that the effect can live without.
- Start the instance again. A failed instance does not retry by itself: remove its token from
data-dioand add it back, or reload. In development, HMR replaces the definition and the instance retries.
An optional model can fail without failing the effect. The asset error still prints under asset:<url>:
import { effect } from '@dioramajs/diorama'
export default effect(async ({ model, place }) => { const lamp = await model('/models/lamp.glb').catch(() => undefined) if (lamp) place(lamp, { fit: 'contain' })})Related
EFFECT_UPDATEEFFECT_TARGETASSET_LOADctx.model()ctx.texture()data-dio-state