Backport commit 673777.