In WidgetKit, how to refresh automatically after the request fails?

I tried not calling completion in gettimeline. After about 40s, the system will call gettimeline again, but after 5 times, if completion is still not called, the widget refresh will be disordered. The set Timeline does not take effect, and the active call to WidgetCenter.shared.reloadAllTimelines() does not take effect. So now I didn't find a proper way to auto refresh. sample code:

struct Provider: IntentTimelineProvider {

    static var count = 0

    func placeholder(in context: Context) -> SimpleEntry {
        return SimpleEntry(date: Date(), name: "")
    }

    func getSnapshot(for configuration: OpenWidgetConfigIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
        let entry = SimpleEntry(date: Date(), name: "")
        completion(entry)
    }

    func getTimeline(for configuration: OpenWidgetConfigIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
        if Self.count < 4 {
            Self.count = Self.count + 1
            return
        } else {
           Self.count = 0
        }
        doTimeLineCompletion(name: "Sir Isaac Newton", image: nil, completion: completion)
    }
    
    func doTimeLineCompletion(name: String, image: UIImage?, completion: @escaping (Timeline<Entry>) -> ()) {
        var entries: [SimpleEntry] = []
        
        var entry = SimpleEntry(date: Date(), name: name)
        
        entries.append(entry)
        
        let timeline = Timeline(entries: entries, policy: .after(Date().addingTimeInterval(TimeInterval(300))))
        completion(timeline)
    }
}

struct SimpleEntry: TimelineEntry {
    let date: Date
    let name: String
}
In WidgetKit, how to refresh automatically after the request fails?
 
 
Q