Backport #11033 to master

Backport #11033 to master.

/cc @fxn