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

can.Model Fails Silently When Server Doesn't Return an Array for findAll #384

Merged
merged 1 commit into from Jul 24, 2013

Conversation

daffl
Copy link
Contributor

@daffl daffl commented Jul 24, 2013

No deferred method is executed if invalid data is returned. For example:

myModel.findAll({myData: 'myValue'}, function(result) {
    // do something here
}).fail(function(xhr, textStatus, errorThrown) {
  // do something here
});

Success callback or fail callback not called. This hold true for 'then'.

@daffl
Copy link
Contributor

daffl commented May 10, 2013

Could you verify this happening in all cases or just for cross domain requests as mentioned in #385? How did you implement findAll, update etc. in the cross domain case? Afaik, JSONP requests don't explicitly fail, you actually have to examine the response and fail the deferred yourself.

@maurerbot
Copy link
Author

We made a fiddle to demonstrate this. Looks like the deferred is called with an ajax but not the model.

http://jsfiddle.net/mattseburn/vTnDS/1/

We aren't doing any cross domain requests. It was actually a coincidence that we noticed this behaviour because a local apache proxies wasn't set up. But it would be nice to know if a JSONP requests possible with can.Model to inspect the response?

daffl added a commit that referenced this pull request Jul 24, 2013
can.Model Fails Silently When Server Doesn't Return an Array for findAll
@daffl daffl merged commit bf64247 into master Jul 24, 2013
@daffl daffl deleted the reject-findalls-384 branch July 24, 2013 00:14
@daffl
Copy link
Contributor

daffl commented Jul 24, 2013

Allright, the findAll and findOne deferreds now reject when an exception gets thrown during .model or .models conversion and the default .models throws an error if it can't convert the data (i.e. the data is undefined).

@justinbmeyer
Copy link
Contributor

So was can.Model truly silently failing (no error in the console), or was the fail not called?

IMO, an error is a different case than a ajax request fails to load. I'm not sure the try-catch was ever appropriate.

daffl added a commit that referenced this pull request Aug 30, 2013
Catch only exceptions thrown by model[func]() (fix #454 and re #384)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants