Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion block gets executed twice on failure #6

Closed
mehlkelm opened this issue Jan 8, 2017 · 5 comments
Closed

Completion block gets executed twice on failure #6

mehlkelm opened this issue Jan 8, 2017 · 5 comments
Assignees
Labels

Comments

@mehlkelm
Copy link
Contributor

mehlkelm commented Jan 8, 2017

If I parse data which happens to not be a valid feed, the completion block gets executed twice.
In Parser.swift, once in line 119 and once in line 242, which is, I believe an XMLParser delegate method. I don't know the FeedKit architecture enough to judge which one is superfluous, though.

One way to reproduce the error: Add this in the sample projects applicationDidFinishLaunching:
let url = URL(string: "https://tageswoche.ch")
URLSession.shared.dataTask(with: url! as URL) { (data, response, error) in
FeedParser(data: data!).parse({ (result) in
print("ERROR")
})
}.resume()

You will see that "ERROR" gets printed twice!

@mehlkelm mehlkelm changed the title Completion Block gets executed twice on failure Completion block gets executed twice on failure Jan 8, 2017
@nmdias nmdias self-assigned this Jan 9, 2017
@nmdias nmdias added the bug label Jan 9, 2017
@mehlkelm
Copy link
Contributor Author

Hm… now the same happens with the parserDidEndDocument delegate method. Am I misunderstanding this?
Is the call to the completion handler from any delegate method needed at all?

@nmdias
Copy link
Owner

nmdias commented Jan 14, 2017

I think I see what's happening. Yes, it is needed in order to provide error information to the user.

However, from what you're telling me and what i've gathered just by quickly looking at it, I'll need to cancel any subsequent errors to the first error found. But I'll take a closer look in the next coming days to determine the most appropriate fix and release a new version.

Are you using any public feeds that you could share to better replicate the error?

Thanks @mehlkelm!

@mehlkelm
Copy link
Contributor Author

I have a workflow where the user can input any URL to subscribe to a feed. First I check if the data at the URL happens to be a valid feed (with FeedKit) which it is most often not. That's where I am running into these errors. Examples I used: tageswoche.ch, zoziapps.ch

@nmdias
Copy link
Owner

nmdias commented Jan 21, 2017

Ok, so it should be fixed now.

Great catch by the way, like you said, the call to the completion handler from the delegate methods were indeed causing the issues.

Could you check if it's running fine now?

Thanks :)

@mehlkelm
Copy link
Contributor Author

Looks fine. Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants