Fix infinite loop when maxpriority===undefined