backport this piece from 5.6, related to the #66307 fix