Backport 6df456f8fc6d.