I’d actually sort of welcome a Chinese attack on Taiwan for that very reason - failure would likely bring down the whole ChiCom regime.
And success could stifle dissent at home against that regime, and solidify the "ChiCom" government's control over the country.