Why did my rear derailleur fail in the middle sprocket?
From the information available I would advise you to make sure:


Chain is of correct length
Derailleur is not running too close to the cassette (B-screw adjustment)


In the workstand pay close attention to what happens with chain on the largest chainring and simultaneously shifting towards the largest sprockets, especially if shifting several gears at once.

I've seen cases where the chain and derailleur can get jammed with the cassette here when derailleur is setup too close to cassette, leading to situations such as this.