fix race with concurrent event emitting