Make sure we wait for the correct child

Fixes #27962.