Fixes #29076 (closed)
Separate PR so that we cherry pick it in v4-dev. I'll rebase #29048 after this @mdo.