{ "id": "82767", "key": "AC-3033", "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": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2011-12-21T19:56:26.000+0000", "created": "2011-11-16T04:19:57.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:48:04.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": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Hi.\r\n\r\nSee this simple code:\r\n\r\n{code}\r\n//app.js\r\nvar testModule = require('test');\r\n \r\ntestModule.doTest();\r\n \r\n \r\n//test.js\r\nvar moduleScope = this;\r\n \r\nexports.doTest = function() {\r\n Ti.API.debug(moduleScope);\r\n};\r\n{code}\r\n\r\n\r\nIt brakes the app and, IMHO, it shouldn't brake in a way it brakes now (\"StackOverflowError\"), in worst case \"moduleScope\" should throw \"ReferenceError\" (\"moduleScope\" is not defined).\r\n\r\n\r\nI'm not sure how CommonJS and module scope behaves, but this also could be legal code and it shouldn't brake at all.", "attachment": [], "flagged": false, "summary": "Android: CommonJS brakes when trying to use global scope reference inside exported function", "creator": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "* Titanium SDK version: 1.7.6 (11/14/11 10:41 2de9cc7...)\r\n* Android 2.2 (Samsung Galaxy Tab v7)\r\n* Windows XP x64\r\n\r\n", "comment": { "comments": [ { "id": "172887", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Ah yes, I forgot about Q/A link: http://developer.appcelerator.com/question/128188/commonjs-brakes-when-trying-to-use-global-scope-reference-inside-function", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-11-16T04:20:46.000+0000", "updated": "2011-11-16T04:20:46.000+0000" }, { "id": "176980", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Ivan, the test case is now not showing the error as of Titanium 1.8.0.1 (2011/12/17 19:53 c903964) + Android APIs 2.2. This could have been fixed in the meantime. See logcat output below.\r\n\r\n{code}\r\n 463 AndroidRuntime D >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<\r\n 463 AndroidRuntime D CheckJNI is ON\r\n 463 AndroidRuntime D --- registering native functions ---\r\n 60 ActivityManager I Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.testing.testing9/.\r\n Testing9Activity }\r\n 463 AndroidRuntime D Shutting down VM\r\n 463 jdwp D Got wake-up signal, bailing out of select\r\n 60 ActivityManager I Start proc com.testing.testing9 for activity com.testing.testing9/.Testing9Activity: pid=470 uid=10040 gids={1015, 3003}\r\n 470 TiApplication I (main) [0,0] checkpoint, app created.\r\n 470 TiApplication I (main) [797,797] Titanium 1.8.0.1 (2011/12/17 19:53 c903964)\r\n 470 TiFastDev D (main) [613,1410] Enabling Fastdev on port 45406\r\n 470 TiFastDev D (main) [156,1566] sent tokens successfully\r\n 470 TiFastDev D (main) [1,1567] Fastdev session handshake succesful.\r\n 470 TiApplication I (main) [23,1590] Titanium Javascript runtime: v8\r\n 470 TiApplication W (main) [266,1856] activity stack is emtpy, unable to get current activity\r\n 470 TiRootActivity I (main) [0,0] checkpoint, on root activity create, savedInstanceState: null\r\n 470 TiApplication W (main) [528,528] activity stack is emtpy, unable to get current activity\r\n 470 TiApplication W (main) [0,528] activity stack is emtpy, unable to get current activity\r\n 470 TiApplication W (main) [3,531] activity stack is emtpy, unable to get current activity\r\n 470 TiApplication E (KrollRuntimeThread) [2684,3215] APP PROXY: ti.modules.titanium.app.AppModule@44f738c0\r\n 470 TiAssetHelper D Fetching \"app.js\" with Fastdev...\r\n 470 Module D Loading module: test1 -> Resources/test1.js\r\n 470 TiAssetHelper D Fetching \"test1.js\" with Fastdev...\r\n 470 TiRootActivity I (main) [0,0] checkpoint, on root activity resume. activity = com.testing.testing9.Testing9Activity@44f49b18\r\n 60 ActivityManager W Launch timeout has expired, giving up wake lock!\r\n 60 ActivityManager I Displayed activity com.testing.testing9/.Testing9Activity: 10600 ms (total 10600 ms)\r\n 470 TiAnalyticsSvc W (Thread-12) [25660,25660] Analytics Service Started\r\n 470 TiAnalyticsSvc I (Thread-12) [135,25795] Sending 1 analytics events.\r\n 470 TiAnalyticsSvc W (Thread-12) [1686,27481] Stopping Analytics Service\r\n{code}\r\n\r\nI'll close this for now, but reopen it if you still see the problem.", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-21T19:56:06.000+0000", "updated": "2011-12-21T19:56:06.000+0000" }, { "id": "176990", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "I can confirm that it has been fixed.\r\n\r\n\r\nThanks.", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-12-22T00:49:10.000+0000", "updated": "2011-12-22T00:49:10.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }