swarm icon indicating copy to clipboard operation
swarm copied to clipboard

lookup timeout on feed content recovery

Open santicomp2014 opened this issue 5 years ago • 0 comments

In #2202 the timeout for getFeedContent was removed.

There seems to be an issue with the context that is passed down to the feed operations.

If there is a context timeout (starting from the download) that expires before reaching getFeedContent, then the recovery process will fail.

The combination of timeouts (the one from the download + the one from the recovery) is complex and should be tested appropriately to determine if the feed is able to get the content in time.

// getFeedContent creates a feed with the given topic and user, and attempts to fetch its content using the given handler
func getFeedContent(ctx context.Context, handler feed.GenericHandler, topic feed.Topic, user common.Address) ([]byte, error) {
	fd := feed.Feed{
		Topic: topic,
		User:  user,
	}
	query := feed.NewQueryLatest(&fd, lookup.NoClue)
	//ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
        //defer cancel()

	_, err := handler.Lookup(ctx, query)
	// feed should still be queried even if there are no updates
	if err != nil && err.Error() != "no feed updates found" {
		return nil, ErrFeedLookup
	}

	_, content, err := handler.GetContent(&fd)
	if err != nil {
		return nil, ErrFeedContent
	}

	return content, nil
}

santicomp2014 avatar Jun 23 '20 14:06 santicomp2014