Parse server - cloud code save object does not respond.
Environment Setup
Environment 1 - Local :
- MacOS 10.11.2
- latest parse server 2.2.7, express 4.13.4.
- DB: mongoDB on AWS
Environment 2 - AWS : same config and DB with local
- AWS ELB (t2-medium - Amazon Linux AMI 2016.03.0)
- latest parse server 2.2.7, express 4.13.4. (same code with local. deploy using "eb deploy").
- DB: mongoDB on AWS (same DB with local)
Result:
Environment 1 - Local : - Find object [OK] - Increase & Save [OK] - Respond to client around 0-2 second
Environment 2 - AWS : - Find object [OK] - Increase & Save [NOT OK] - Respond to client: not respond and timeout after 1 minute. nginx access log: 10.0.2.69 - - [03/May/2016:13:40:15 +0000] "POST /parse/functions/test HTTP/1.1" 499 0 "-" "curl/7.43.0" "171.233.241.183"
Steps to reproduce
Follow this one http://stackoverflow.com/questions/36945845/parse-server-cloud-code-save-object but no luck.
Code:
var SaveObject = Parse.Object.extend("UserProfile"); var saveObject = new Parse.Query(SaveObject); saveObject.equalTo("objectId", request.params.objectId); saveObject.first({ useMasterKey: true, success: function(Objects) { console.log("Successfully retrieved"); Objects.save(null, { useMasterKey: true, success: function(object) { console.log("Start Save 2 Successfully"); object.increment("noteRating"); object.save(); console.log("Cloud Code: User note rating has increased by 1.", object); status.success('Cloud Code: User note rating has increased by 1.'); } }); } });
Logs/Trace
Environment 1 - Local:
Successfully retrieved Start Save 2 Successfully Cloud Code: User note rating has increased by 1. ParseObjectSubclass { className: 'UserProfile', _objCount: 17, id: '1GTlCTiNC4' } response: { "response": { "result": "Cloud Code: User note rating has increased by 1." } }
Environment 2 - AWS : Successfully retrieved -> stuck
Important Note:
Make several request, The result is random. noteRating is increased and saved around 50% after random amount of time. All requests were time out.
Please help!!!
You are returning from the cloud code function while the save() call is still processing. Use .save().then(...) or a success callback. See the docs for more info.
thank. It worked