Backport of 9c19aff7c7561e3a82978a272ecdaad40dda5c00 from main.
Regression in 49b679371fe9beddcd23a93b5fdbadea914f37f8.