Search code examples
parse-platformparse-cloud-code

Calling Cloud Job from Cloud Function via httpRequest always succeeds, even if job fails


I'm trying to test my Cloud Job "processAllOrders" by calling it from "testProcessAllOrders"(which I later call from a bash script). It seems that the job, whether it fails or succeeds, always returns an empty response with status 201. Is this by design? Am I doing something wrong?

Thanks!

/** Job Testing **/ 
Parse.Cloud.define("testProcessAllOrders", function(request, response) {
    return Parse.Cloud.httpRequest({
        method: "POST",
        url: "https://api.parse.com/1/jobs/processAllOrders",
        headers: {
        "X-Parse-Application-Id": "xxx",
        "X-Parse-Master-Key": "xxx",
        "Content-Type": "application/json"
        },
        body: { }
    }).then(function(httpResponse) {
        console.log("httpResponse: " + httpResponse.text + " status: " + httpResponse.status);
        response.success("testProcessAllOrders passed");
    }, function() {
        response.error("testProcessAllOrders failed: " + error.message);
    });
});

// *** Jobs *** //
Parse.Cloud.job("processAllOrders", function(request, status) {
    status.error("failed");
});

Solution

  • That call may just be to start the job, is my guess. Cloud functions have a 15 second timeout, and jobs have a 15 minute timeout. So It wouldn't make sense for a function to be able to wait for a job to finish every time.