drew..
drew..

Reputation: 3584

Parse Cloudcode error branch taking 60seconds+ to return: why?

I flipped over to back4app, running Parse, and so far looooove it. I am working on a simple bit of cloudcode the seems to fight me at every step.

This idea: send up a channel string, do a simple find via Parse.Installation, and return a field in the first found record. Works like a charm WHEN the channel is found.

The issue: it takes over 60 seconds to return if no record is found. Return time for a found record is usually a split-second. I am not a javascript guru, and have tried numerous variants to no avail, and JSLint seems to not want to test out a Parse.Cloudcode.Define block.

The question: how structurally messed up am i here to cause this kind of delay? I am simply not seeing the issue. Any thoughts are most welcome:

Parse.Cloud.define("test", function(request, response) {

               var query = new Parse.Query(Parse.Installation);
               query.equalTo("channels", request.params.other);
               query.descending("updatedAt");
               query.first({
                           useMasterKey: true,
                           success: function(installation) {
                           response.success(installation.get("lastLoginAt"));
                           },
                           error: function(error) {
                           response.error("test");
                           }
                           });
               });

{edited function for useMasterKey: true ... no changes seen with timing issue}

Upvotes: 0

Views: 75

Answers (1)

cYrixmorten
cYrixmorten

Reputation: 7108

Not seeing any obvious issues, I'll just leave a snippet of how I would write it:

Parse.Cloud.define("test", function(request, response) {
    var query = new Parse.Query(Parse.Installation);
    query.equalTo("channels", request.params.other);
    query.descending("updatedAt");
    query.first({useMasterKey: true})
        .then(function(installation) {
            if (installation) {
                response.success(installation.get("lastLoginAt"));
            } else {
                response.error("No installation with channel: " + request.params.other);
            }
        })
});

Upvotes: 1

Related Questions