Partically backport #24330 Related: #24176 Maybe fix #24770 (cherry picked from commit 64cc691b7f5977915b686bdf85e4c6ffe9692a35)