Re-submit of #17120

Was originally reverted by #17187 but is now fixed up.