Fix a startup exception caused by race condition