{ "id": "144096", "key": "AC-1159", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2015-02-05T15:58:11.000+0000", "created": "2015-02-03T09:16:18.000+0000", "labels": [ "TCSupportTriage" ], "versions": [], "issuelinks": [], "assignee": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "updated": "2016-03-08T07:37:31.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "Titanium 3.5, Alloy 1.5.1, latest TiStudio, iPhone 5s simulator with iOS 8.1.\r\n\r\nAll alloy.fetch() calls return undefined instead of a promise.\r\n\r\nThe issue is in https://github.com/appcelerator/alloy/blob/1_3_X/Alloy/lib/alloy.js line 139 (latest version):\r\nextendObj.sync = function(method, model, opts) {\r\n mod.sync(method, model, opts);\r\n};\r\n\r\nShould be:\r\n\r\nextendObj.sync = function(method, model, opts) {\r\n return mod.sync(method, model, opts);\r\n};\r\n\r\nNote: there is a second instance of the same issue later on in the file, which exposes the same issue and needs to be fixed again.", "attachment": [], "flagged": false, "summary": "Backbone fetch() returns undefined when run from TiStudio on Titanium 3.5/Alloy 1.5.1", "creator": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "342022", "author": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Updated description to state that there is a 2nd instance of the same issue in the same file. We hit the same issue in another part of the code and adding the return statement fixes this issue too.", "updateAuthor": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-02-04T11:51:42.000+0000", "updated": "2015-02-04T11:51:42.000+0000" }, { "id": "342035", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello Eric,\r\ndo you mind to provide a simple testcase that shows the issue? Then we can add your fix as suggested fix to engineering. \r\n\r\nBest Regards", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2015-02-04T14:45:21.000+0000", "updated": "2015-02-04T14:45:21.000+0000" }, { "id": "342050", "author": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi,\r\n\r\nI won't have time to create a self-contained project but basically it happens when using a model that returns a promise and try to execute:\r\nAlloy.createModel(\"test\").fetch().then(function(data) {\r\n\tTi.API.log(\"info\", \"In then\");\r\n}).catch(function(data) {\r\n\tTi.API.log(\"info\", \"In catch\");\r\n});\r\n\r\nThis used to work in older versions of Titanium but now breaks. Interestingly enough, it only breaks when compiling from TiStudio, but it works when compiling from the CLI.\r\n\r\nSo the question is: is fetch() returning a value supported? This is extremely valuable when using an async adapter, as opposed to getting into callback or event hell.\r\n\r\nI actually just found someone experiencing the same issue and documenting the same fix:\r\nhttps://github.com/aaronksaunders/tiConnectSampleApp\r\n\r\nLook for \"Hacking of alloy.js to get promises to work\".\r\nSo this project (tiConnectSampleApp) can be used as a sample to show the advantage of adding a return statement in these 2 places.\r\n\r\nLooking at the backbone doc for fetch(), it is supposed to return a jqXHR, so in theory it should be able to return something.\r\nIt may be slightly outside of the scope of Titanium - I'll let you decide, but being able to use promises is a great advantage.", "updateAuthor": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-02-04T15:36:20.000+0000", "updated": "2015-02-04T15:36:20.000+0000" }, { "id": "342215", "author": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "eric_thiebaut", "key": "eric_thiebaut", "displayName": "Eric Thiebaut-George", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-02-05T08:49:29.000+0000", "updated": "2015-02-05T08:49:29.000+0000" }, { "id": "342241", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2015-02-05T15:58:11.000+0000", "updated": "2015-02-05T15:58:11.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }