From 5d5f263a113ee10c35606e964b8ded0e19b26d9f Mon Sep 17 00:00:00 2001 From: Derek van Vliet Date: Thu, 18 Feb 2016 09:24:24 -0500 Subject: [PATCH 1/2] added PromiseWithoutRejectedCallbackFail I added a function that demonstrates issue #456. I'm finding that if I don't specify a rejected callback for the Parse.Config.get() promise's Then method, it never reaches my When method and the function times out. I found this worked in hosted parse but not in the open source version. https://github.com/ParsePlatform/parse-server/issues/456 --- src/cloud/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cloud/main.js b/src/cloud/main.js index fec259910a..5ecc3991da 100644 --- a/src/cloud/main.js +++ b/src/cloud/main.js @@ -102,3 +102,20 @@ Parse.Cloud.define('requiredParameterCheck', function(req, res) { }, function(params) { return params.name; }); + +Parse.Cloud.define("PromiseWithoutRejectedCallbackFail", function(request, response) { + var promises = []; + var result = {}; + + // fetch config + result.config = {}; + + promises.push(Parse.Config.get().then(function(config) { + result.config = config.attributes; + })); + + // wait for all promises to finish + Parse.Promise.when(promises).then(function() { + response.success(result); + }); +}); From f0ffc27ab6cf4717639a26ab6cf5ef42184e69ea Mon Sep 17 00:00:00 2001 From: Derek van Vliet Date: Fri, 19 Feb 2016 12:11:49 -0500 Subject: [PATCH 2/2] added unit test for PromiseWithoutRejectedCallbackFail --- spec/ParseAPI.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 67e414b752..9278d0f768 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -721,4 +721,14 @@ describe('miscellaneous', function() { }); }); + it('fetches the config using a promise', done => { + Parse.Cloud.run('PromiseWithoutRejectedCallbackFail').then((s) => { + expect(s instanceof Object).toBe(true); + expect(s.config instanceof Object).toBe(true); + done(); + }, (e) => { + fail(e); + }); + }); + });