{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/2562","labels_url":"https://api.github.com/repos/facebook/react-native/issues/2562/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/2562/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/2562/events","html_url":"https://github.com/facebook/react-native/issues/2562","id":105025294,"number":2562,"title":"[UIExplorer] Example won't run","user":{"login":"lowellbander","id":3479724,"avatar_url":"https://avatars.githubusercontent.com/u/3479724?v=3","gravatar_id":"","url":"https://api.github.com/users/lowellbander","html_url":"https://github.com/lowellbander","followers_url":"https://api.github.com/users/lowellbander/followers","following_url":"https://api.github.com/users/lowellbander/following{/other_user}","gists_url":"https://api.github.com/users/lowellbander/gists{/gist_id}","starred_url":"https://api.github.com/users/lowellbander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lowellbander/subscriptions","organizations_url":"https://api.github.com/users/lowellbander/orgs","repos_url":"https://api.github.com/users/lowellbander/repos","events_url":"https://api.github.com/users/lowellbander/events{/privacy}","received_events_url":"https://api.github.com/users/lowellbander/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-05T12:53:13Z","updated_at":"2015-10-02T01:10:47Z","closed_at":null,"body":"When I run the UIExplorer Example either in the simulator or my device, I receive the following error:\r\n\r\n```Bridge modules have not yet been initialized. You may be trying to access a module too early in the startup procedure.```\r\n\r\nMy search for solutions to this issue has been wholly unfruitful thus far."},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/144892489","html_url":"https://github.com/facebook/react-native/issues/2562#issuecomment-144892489","issue_url":"https://api.github.com/repos/facebook/react-native/issues/2562","id":144892489,"user":{"login":"jedlinlau","id":1895927,"avatar_url":"https://avatars.githubusercontent.com/u/1895927?v=3","gravatar_id":"","url":"https://api.github.com/users/jedlinlau","html_url":"https://github.com/jedlinlau","followers_url":"https://api.github.com/users/jedlinlau/followers","following_url":"https://api.github.com/users/jedlinlau/following{/other_user}","gists_url":"https://api.github.com/users/jedlinlau/gists{/gist_id}","starred_url":"https://api.github.com/users/jedlinlau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedlinlau/subscriptions","organizations_url":"https://api.github.com/users/jedlinlau/orgs","repos_url":"https://api.github.com/users/jedlinlau/repos","events_url":"https://api.github.com/users/jedlinlau/events{/privacy}","received_events_url":"https://api.github.com/users/jedlinlau/received_events","type":"User","site_admin":false},"created_at":"2015-10-02T01:10:47Z","updated_at":"2015-10-02T01:10:47Z","body":"On 0.11.4, I think I see a race condition between RCTBatchedBridge's `invalidate` and line 464 within `invalidate` that sets `_modulesByName` to nil. When I step through this code in the debugger, I see RCTBridge call `invalidate` due to a reload. Next, RCTBridge calls `[self setUp]`, which goes through the initialization of the modules again:\r\n```obj-c\r\n        -[RCTModuleData initWithExecutor:moduleID:instance:] + 792                                                                                                                   \r\n        5   Samsara                             0x000000010b217f61                                                                                                                   \r\n        -[RCTBatchedBridge initModules] + 3617                                                                                                                                       \r\n        6   Samsara                             0x000000010b2157da                                                                                                                   \r\n        -[RCTBatchedBridge start] + 282                                                                                                                                              \r\n        7   Samsara                             0x000000010b215660                                                                                                                   \r\n        -[RCTBatchedBridge initWithParentBridge:] + 1744                                                                                                                             \r\n        8   Samsara                             0x000000010b2398b8\r\n```\r\n\r\nBut, in the middle of this initialization, the debugger jumps to line 464 in RCTBatchedBridge.m:\r\n```obj-c\r\n  dispatch_group_notify(group, dispatch_get_main_queue(), ^{\r\n    [_javaScriptExecutor executeBlockOnJavaScriptQueue:^{\r\n      [_jsDisplayLink invalidate];\r\n      _jsDisplayLink = nil;\r\n\r\n      [_javaScriptExecutor invalidate];\r\n      _javaScriptExecutor = nil;\r\n\r\n      if (RCTProfileIsProfiling()) {\r\n        RCTProfileUnhookModules(self);\r\n      }\r\n      _moduleDataByID = nil;\r\n>>>>  _modulesByName = nil;   <<<<\r\n      _frameUpdateObservers = nil;\r\n\r\n    }];\r\n  });\r\n```\r\n\r\nThis nils out `_modulesByName` in the middle of initialization. When initialization of the modules continues, `[RCTBatchedBridge modules]` evaluates the assert, which fails. (`self.isValid` is YES, but `_modulesByName` is nil.)"}}