Cherry-picked 42869e88e45e3ea6c3e3a07678982f6e835ff274