{"action":"created","issue":{"url":"https://api.github.com/repos/parse-community/parse-server/issues/4930","repository_url":"https://api.github.com/repos/parse-community/parse-server","labels_url":"https://api.github.com/repos/parse-community/parse-server/issues/4930/labels{/name}","comments_url":"https://api.github.com/repos/parse-community/parse-server/issues/4930/comments","events_url":"https://api.github.com/repos/parse-community/parse-server/issues/4930/events","html_url":"https://github.com/parse-community/parse-server/issues/4930","id":347639346,"node_id":"MDU6SXNzdWUzNDc2MzkzNDY=","number":4930,"title":"Modernization of hooks and functions","user":{"login":"flovilmart","id":364568,"node_id":"MDQ6VXNlcjM2NDU2OA==","avatar_url":"https://avatars3.githubusercontent.com/u/364568?v=4","gravatar_id":"","url":"https://api.github.com/users/flovilmart","html_url":"https://github.com/flovilmart","followers_url":"https://api.github.com/users/flovilmart/followers","following_url":"https://api.github.com/users/flovilmart/following{/other_user}","gists_url":"https://api.github.com/users/flovilmart/gists{/gist_id}","starred_url":"https://api.github.com/users/flovilmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flovilmart/subscriptions","organizations_url":"https://api.github.com/users/flovilmart/orgs","repos_url":"https://api.github.com/users/flovilmart/repos","events_url":"https://api.github.com/users/flovilmart/events{/privacy}","received_events_url":"https://api.github.com/users/flovilmart/received_events","type":"User","site_admin":false},"labels":[{"id":319165145,"node_id":"MDU6TGFiZWwzMTkxNjUxNDU=","url":"https://api.github.com/repos/parse-community/parse-server/labels/pr-submitted","name":"pr-submitted","color":"207de5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":33,"created_at":"2018-08-04T18:36:27Z","updated_at":"2018-08-19T23:39:52Z","closed_at":"2018-08-15T14:47:22Z","author_association":"MEMBER","body":"**Is your feature request related to a problem? Please describe.**\r\n\r\nRight now, we still rely on the legacy backbone style success / error callback methods. With node.js moving forward at an incredible pace, I believe it's time to make the cloud functions enter the 21st century supporting async / await, promises and more\r\n\r\n**Describe the solution you'd like**\r\n\r\n- Support promises, async/await in cloud code as valid return values for hooks and functions\r\n- Mark calls to success / error callbacks deprecated in Cloud Code (with a big fat warning)\r\n- Later on, remove success / error implementations\r\n\r\n\r\nCloud funcitons would look like:\r\n\r\n```\r\nParse.Cloud.beforeSave('ClassName', async ({ object }) => {\r\n    await doSomething();\r\n    if (somethingsFishy(object)) {\r\n        throw new Error('OOps')\r\n    }\r\n    return;\r\n});\r\n\r\n// Also valid\r\nParse.Cloud.beforeSave('ClassName', async ({ object }) => {\r\n    await doSomething();\r\n    if (somethingsFishy(object)) {\r\n        return new Error('OOps'); // returning an error is also allowed\r\n    }\r\n});\r\n```\r\n\r\nFor functions:\r\n\r\n```\r\nParse.Cloud.define('MyFunction', async ({ params }) => {\r\n    await doSomething();\r\n    if (!param.isValid) {\r\n        return new Error('OOps'); // returning an error is also allowed\r\n    }\r\n    return 'OK!';\r\n});\r\n```\r\n\r\ncc: @acinader , @dplewis "},"comment":{"url":"https://api.github.com/repos/parse-community/parse-server/issues/comments/414164239","html_url":"https://github.com/parse-community/parse-server/issues/4930#issuecomment-414164239","issue_url":"https://api.github.com/repos/parse-community/parse-server/issues/4930","id":414164239,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDE2NDIzOQ==","user":{"login":"danepowell","id":1984514,"node_id":"MDQ6VXNlcjE5ODQ1MTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1984514?v=4","gravatar_id":"","url":"https://api.github.com/users/danepowell","html_url":"https://github.com/danepowell","followers_url":"https://api.github.com/users/danepowell/followers","following_url":"https://api.github.com/users/danepowell/following{/other_user}","gists_url":"https://api.github.com/users/danepowell/gists{/gist_id}","starred_url":"https://api.github.com/users/danepowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danepowell/subscriptions","organizations_url":"https://api.github.com/users/danepowell/orgs","repos_url":"https://api.github.com/users/danepowell/repos","events_url":"https://api.github.com/users/danepowell/events{/privacy}","received_events_url":"https://api.github.com/users/danepowell/received_events","type":"User","site_admin":false},"created_at":"2018-08-19T23:39:52Z","updated_at":"2018-08-19T23:39:52Z","author_association":"NONE","body":"That doesn't really make sense to me, since I've defined the job as `async` and all of my calls to other async functions within the job use `await`. So the job shouldn't be returning instantly, assuming Parse Server is properly calling the job using await or Promises.\r\n\r\nAdditionally, I've confirmed that the exact same code works fine as a cloud function but not a cloud job, which leads me to think this is a bug. I've opened https://github.com/parse-community/parse-server/issues/4995"}}
{"actor":{"display_login":"danepowell"}}