{"action":"created","issue":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/issues/416","repository_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android","labels_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/issues/416/labels{/name}","comments_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/issues/416/comments","events_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/issues/416/events","html_url":"https://github.com/ParsePlatform/Parse-SDK-Android/issues/416","id":139865011,"number":416,"title":"Android SDK (not JS SDK) replays cloud functions requests that takes 10+s","user":{"login":"jmfayard","id":459464,"avatar_url":"https://avatars.githubusercontent.com/u/459464?v=3","gravatar_id":"","url":"https://api.github.com/users/jmfayard","html_url":"https://github.com/jmfayard","followers_url":"https://api.github.com/users/jmfayard/followers","following_url":"https://api.github.com/users/jmfayard/following{/other_user}","gists_url":"https://api.github.com/users/jmfayard/gists{/gist_id}","starred_url":"https://api.github.com/users/jmfayard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmfayard/subscriptions","organizations_url":"https://api.github.com/users/jmfayard/orgs","repos_url":"https://api.github.com/users/jmfayard/repos","events_url":"https://api.github.com/users/jmfayard/events{/privacy}","received_events_url":"https://api.github.com/users/jmfayard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/labels/good%20first%20task","name":"good first task","color":"b692ff"},{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/labels/help%20wanted","name":"help wanted","color":"3cb92c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-10T11:48:08Z","updated_at":"2016-03-24T09:37:51Z","closed_at":null,"body":"Say you have a cloud function that bill your customer. If by bad luck it takes more than 10s to complete, your customer will be billed many times because the Android SDK (but not the JS or iOS SDK) replays the cloud function request.\r\n\r\nThis issue has been raised before\r\nhttps://github.com/ParsePlatform/Parse-SDK-Android/issues/224\r\nhttps://github.com/ParsePlatform/Parse-SDK-Android/issues/367\r\n\r\nI am able to reproduce it reliably by creating a cloud function that waits a given timeout before completing\r\n\r\n```\r\n// pseudo code\r\n Parse.Cloud.define(\"test\", function (request, response) {\r\n      hasParam: timeout (in miliseconds)\r\n      log(\"waiting $timeout miliseconds\")\r\n      wait($timeout)\r\n      log(\"completed after $timeout miliseconds\")\r\n      response.success()\r\n}\r\n\r\n// real code\r\nhttps://gist.github.com/jmfayard/5e866c6b9a6f12902692      \r\n```    \r\n\r\nIf I call my function in a javascript console, I have the expected behavior\r\n\r\n```\r\nJS console> Parse.Cloud.run(\"test\", { timeout: 14000}).then(success, error)\r\nJS result>     \"completed after 14000 miliseconds\"\r\nParse logs>  I2016-03-10T10:48:49.292Z] (test) waiting 14000 miliseconds\r\nParse logs>  I2016-03-10T10:49:03.297Z] (test) completed after 14000 miliseconds\r\n\r\nJS console> Parse.Cloud.run(\"test\", { timeout: 18000}).then(success, error)\r\nJS result>     error = \"Execution timed out\"\r\nParse logs>  I2016-03-10T10:49:08.416Z] (test) waiting 18000 miliseconds\r\n```\r\n\r\nIf I do the same thing on Android\r\n\r\n```\r\npublic class ParseCloudFunctionsPlugin extends StethoPlugin {\r\n        //...\r\n        out.printf(\"Testing timeout: 2seconds, 13 seconds, 23seconds!\");\r\n        tryCallingCloudunction(functions.test(2000));\r\n        tryCallingCloudunction(functions.test(13000));\r\n        tryCallingCloudunction(functions.test(23000));\r\n}\r\n```\r\n\r\n\r\nHere the parse logs show me\r\n\r\n```\r\nI2016-03-10T10:30:34.926Z] (test) waiting 2000 miliseconds\r\nI2016-03-10T10:30:36.927Z] (test) completed after 2000 miliseconds\r\n\r\nI2016-03-10T10:30:37.153Z] (test) waiting 13000 miliseconds\r\nI2016-03-10T10:30:49.461Z] (test) waiting 13000 miliseconds\r\nI2016-03-10T10:30:50.153Z] (test) completed after 13000 miliseconds\r\nI2016-03-10T10:31:02.461Z] (test) completed after 13000 miliseconds\r\nI2016-03-10T10:31:03.328Z] (test) waiting 13000 miliseconds\r\nI2016-03-10T10:31:16.328Z] (test) completed after 13000 miliseconds\r\nI2016-03-10T10:31:24.106Z] (test) waiting 13000 miliseconds\r\nI2016-03-10T10:31:37.106Z] (test) completed after 13000 miliseconds\r\nI2016-03-10T10:31:49.188Z] (test) waiting 13000 miliseconds\r\nI2016-03-10T10:32:02.198Z] (test) completed after 13000 miliseconds\r\n\r\nI2016-03-10T10:31:59.586Z] (test) waiting 23000 miliseconds\r\nI2016-03-10T10:32:11.062Z] (test) waiting 23000 miliseconds\r\nI2016-03-10T10:32:23.422Z] (test) waiting 23000 miliseconds\r\nI2016-03-10T10:32:37.898Z] (test) waiting 23000 miliseconds\r\nI2016-03-10T10:32:56.319Z] (test) waiting 23000 miliseconds\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/issues/comments/200755795","html_url":"https://github.com/ParsePlatform/Parse-SDK-Android/issues/416#issuecomment-200755795","issue_url":"https://api.github.com/repos/ParsePlatform/Parse-SDK-Android/issues/416","id":200755795,"user":{"login":"jmfayard","id":459464,"avatar_url":"https://avatars.githubusercontent.com/u/459464?v=3","gravatar_id":"","url":"https://api.github.com/users/jmfayard","html_url":"https://github.com/jmfayard","followers_url":"https://api.github.com/users/jmfayard/followers","following_url":"https://api.github.com/users/jmfayard/following{/other_user}","gists_url":"https://api.github.com/users/jmfayard/gists{/gist_id}","starred_url":"https://api.github.com/users/jmfayard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmfayard/subscriptions","organizations_url":"https://api.github.com/users/jmfayard/orgs","repos_url":"https://api.github.com/users/jmfayard/repos","events_url":"https://api.github.com/users/jmfayard/events{/privacy}","received_events_url":"https://api.github.com/users/jmfayard/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T09:37:51Z","updated_at":"2016-03-24T09:37:51Z","body":"It's a strange expectation frankly. \r\nSo an app asks the SDK to make a side effect.\r\nBehind the scenes, the SDK make most of the time one side effect so during development, everything looks fine.\r\nBut sometimes, the SDK chooses instead to do behind the scenes 5 side effects.\r\nFrom the perspective of the app, everything looks allright.\r\nFrom the perspective of the server, everything looks like 5 legitimate independant requests for doing a side effects.\r\n"}}