Forward port of issue #19556 to 2.3.0.M1.
Comment From: wilkinsona
This change has been reverted as it introduced a regression. See #19822 for details.
Comment From: wilkinsona
Switching to a task as the changes here and in #19822 cancel each other out in 2.3.0.M1.