When your drone suddenly loses power mid-flight, it's terrifying and can lead to a crash. I've diagnosed hundreds of these cases, and the culprit is almost always related to the power delivery system rather than flight controller settings or firmware.
First, check your battery. A weak or damaged cell will cause voltage sag under load. After landing, immediately measure the voltage of each cell using a multimeter or cell checker. If any cell reads significantly lower than the others, that battery is toast. Even if the pack voltage seems adequate at rest, internal resistance might be too high. I once had a 4S pack that read 16.4V on the bench but dropped to 12V under throttle because one cell had 150 milliohm resistance instead of the normal 10-15. Always verify your battery's C-rating matches your drone's draw. A 1500mAh 45C battery should theoretically handle 67.5A, but real-world performance degrades with age and abuse.
Second, examine every connection in your power chain. A cold solder joint on your XT60 connector or a partially detached motor wire can create intermittent contact that fails under vibration. I heat-shrink all my ESC-to-motor connections after soldering and add a dab of hot glue for mechanical strength. Check your battery balance lead too since some flight controllers use it for voltage monitoring and will cut power if they detect a problem.
ESC thermal protection is another common cause. If you're pushing hard on a hot day, your ESCs might be hitting 100 degrees Celsius and entering protection mode. Feel your ESCs immediately after landing. If they're too hot to touch comfortably, you need better cooling or lower KV motors. I added small heatsinks to my 4-in-1 ESC and gained about 30 seconds more flight time before thermal limits kicked in.
Less common but worth checking: power distribution board damage, a failing BEC that powers your flight controller, or even a loose battery strap that lets the battery shift and momentarily disconnect. I always do a pre-flight wiggle test on my battery to ensure it's secure.
Use blackbox logs if your flight controller supports them. Look for voltage drops correlating with throttle spikes. A healthy setup shouldn't see more than 1-1.5V sag per cell under full throttle. Anything beyond that indicates a power delivery problem that needs immediate attention before your next flight.