Quick answer: Guard the divisor, restructure ratios that can legitimately hit zero (empty inventories, zero max values), and remember float division yields inf/NaN silently instead of erroring.
GDScript errors on integer division by zero, but the deeper issue is a game value that reached zero when the formula assumed it could not. Here is where they hide.
How to fix it
1. Guard computed divisors
Averages over empty arrays (total / items.size()), percentages of zero max HP, and per-second rates over zero elapsed time are the usual suspects — early-return or clamp the divisor.
2. Mind the float difference
Float division by zero does not error — it produces inf or NaN that corrupts positions later. Guard floats too, not just ints.
3. Design zero out of the data
Make minimums explicit: a weapon's fire interval, a level's par time, a unit's max load should be validated > 0 when loaded from data files.
4. Log the inputs at the site
When guarding, log the numerator and context once — a zero that should be impossible usually means an upstream loading or ordering bug worth fixing.
Catching the ones you can't reproduce
The hardest version of this to fix is the one you can't reproduce — it only happens on a player's hardware, OS, driver, or save state, under conditions that simply aren't present on your machine. A report that says “it crashed” or “it froze” gives you nothing to act on, so the bug survives release after release while quietly costing you players.
Automatic error capture closes that gap. Each failure arrives with its full stack trace, the device and OS, the build number, and a breadcrumb trail of what the player did right before it broke, so even a failure you have never seen becomes a specific, reproducible issue. Fold identical failures into one signature ranked by how many players each hits, and your worklist sorts itself worst-first instead of arriving as a stream of vague complaints.
This is where a tool like Bugnet earns its place. Its SDK captures every Godot error automatically with the full stack trace plus device, OS, memory, build, and game-state context, folds duplicates into one grouped issue with an occurrence count, and ties each to the build it first appeared on — so you fix the problem that hurts the most players first and confirm it is gone when its signature disappears from the next release.
A crash you can name from its stack trace is a crash you can usually fix in minutes.