Résumé

A particle field that vanished for good after one theme toggle

The particle field behind the toolkit rendered on load. The first time anyone used the light/dark toggle, it disappeared completely and never came back, in either direction, for the rest of the session.

There was no error in the console. That was the first clue, and I misread it as good news.

The wrong turn

My first hypothesis was that the field simply failed to start under the new theme. It didn't: without toggling, it mounted and animated in both themes. The failure required the toggle, which should have ruled the hypothesis out immediately.

My second hypothesis was a race in the theme watcher, two animations competing to own the same canvas. Also wrong, and also for a reason I could have used: a race clears itself. This bug was stable and wrong indefinitely. A thing that never resolves itself is not a race.

What it actually was

A try/catch around the engine setup, written defensively, swallowed the failure. The catch did its job: it stopped an exception from reaching the console. That was the bug. The code caught the error, discarded it, and left the component in a state where the canvas existed but nothing drew to it.

The fix was to stop tearing the engine down and rebuilding it on a theme change. The particles should change colour, not be destroyed and recreated. The new code mutates the engine's resolved options and refreshes it; the container, the canvas, and the particle array all survive.

The part I actually had to change in myself

The interesting property of this bug is that it is invisible to every check I had. The field was present on load, and the site looked correct in a screenshot. Presence on load does not imply survival across a reload of state, and nothing in a screenshot can tell the difference.

So the guard now toggles the theme four times and asserts the field is still present and still painting after each one, reading the canvas dimensions rather than trusting any status flag the component exposes. A canvas still in the DOM at zero size is the same failure as a canvas that was removed.

The general lesson

A caught-and-ignored error is a defect in its own right, not a defensive measure. It converts a loud failure into a silent one and throws away the only evidence you would have had. I now treat an empty catch as a bug to be justified, not a pattern to be admired.