Description
Issue Description
We are migrating app from api.parse.com. In cloud code we have afterSave triggers on all classes, where we set ACL, and other stuff.
When we save a Class object, and when save() is done, we direct user to URL of that object in form of http://server/OBJECT_ID
. On parse.com - this works. When object.save()
is completed, triggers that set ACL are completed as well, and user can open that URL.
On parse-server, this is not the case. When user is navigated to URL, he gets an error. And if we set timeout like 2sec before navigating user to newly created object, and after save completes, URL works!
We cannot use beforeSave because we need ID of the object being created.
Steps to reproduce
- Create afterSave trigger on a Class that sets public read ACL on an object in cloud code
- Create an instance using Parse API, with restricted access ACL
- Save instance, and when it saves, try to fetch it
Expected Results
User should see his object, because afterSave should set public read ACL when save() is called by user.
Actual Outcome
User gets an error, because ACL is restricted.
If user tries again in 2 sec, he will see this object, because by now afterSave has completed.
Problematic Code (workaround)
So THIS LINE is the root of my problems... I had to return the promise maybeRunTrigger
returns, this chained afterSave promise, and made it sync with RestWrite.execute
. I also had to accept response
in afterSave trigger and call response.success
and response.error
to resolve a promise...
But I guess this is not a parse thing to do because declaration of afterSave
trigger has to change... :)