backport ac43ac3b5168d2e3c7bc526a9a2436a7fd866cc9 to v1.2