Max will fail if crrentAttemps is empty. Furthermore you cannot use taskData as the retryCount is never updated.