{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/1104","labels_url":"https://api.github.com/repos/facebook/react-native/issues/1104/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/1104/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/1104/events","html_url":"https://github.com/facebook/react-native/issues/1104","id":72569293,"number":1104,"title":"Failure to find callback when communicating from native code to Javascript","user":{"login":"bhatti","id":58455,"avatar_url":"https://avatars.githubusercontent.com/u/58455?v=3","gravatar_id":"","url":"https://api.github.com/users/bhatti","html_url":"https://github.com/bhatti","followers_url":"https://api.github.com/users/bhatti/followers","following_url":"https://api.github.com/users/bhatti/following{/other_user}","gists_url":"https://api.github.com/users/bhatti/gists{/gist_id}","starred_url":"https://api.github.com/users/bhatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhatti/subscriptions","organizations_url":"https://api.github.com/users/bhatti/orgs","repos_url":"https://api.github.com/users/bhatti/repos","events_url":"https://api.github.com/users/bhatti/events{/privacy}","received_events_url":"https://api.github.com/users/bhatti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-05-02T02:07:44Z","updated_at":"2015-05-06T02:02:06Z","closed_at":null,"body":"I am writing a native module which allows Javascript client to register for events with a callback and then receive events. I used examples from http://facebook.github.io/react-native/docs/nativemodulesios.html, e.g.\r\n\r\n-(void)subscribe:(NSString *)event withCallback:(RCTResponseSenderBlock) callback;\r\n\r\nand used RCT macros to expose those methods.\r\n\r\nI then connected to the module from Javascript, e.g.\r\nvar SubscriptionManager = require('NativeModules').SubscriptionManager;\r\n SubscriptionManager.subscribe(\"type\", function(error, events) {...});\r\n\r\nWhen I run the app, I receive events for a few seconds and then the native code fails to send event with warning:\r\n\r\n2015-05-01 18:59:12.904 [info][tid:com.facebook.React.JavaScript] \"Warning: Cannot find callback with CBID 73. Native module may have invoked both the success callback and the error callback.\"\r\n\r\nand the app crashes with error \r\n![crash](https://cloud.githubusercontent.com/assets/58455/7439557/47013ed6-f035-11e4-8189-14b28682f9c0.png)\r\n\r\nCan someone suggest fix for this issue?\r\n\r\nThanks.\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/99287920","html_url":"https://github.com/facebook/react-native/issues/1104#issuecomment-99287920","issue_url":"https://api.github.com/repos/facebook/react-native/issues/1104","id":99287920,"user":{"login":"ide","id":379606,"avatar_url":"https://avatars.githubusercontent.com/u/379606?v=3","gravatar_id":"","url":"https://api.github.com/users/ide","html_url":"https://github.com/ide","followers_url":"https://api.github.com/users/ide/followers","following_url":"https://api.github.com/users/ide/following{/other_user}","gists_url":"https://api.github.com/users/ide/gists{/gist_id}","starred_url":"https://api.github.com/users/ide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ide/subscriptions","organizations_url":"https://api.github.com/users/ide/orgs","repos_url":"https://api.github.com/users/ide/repos","events_url":"https://api.github.com/users/ide/events{/privacy}","received_events_url":"https://api.github.com/users/ide/received_events","type":"User","site_admin":false},"created_at":"2015-05-06T02:02:06Z","updated_at":"2015-05-06T02:02:06Z","body":"This might be possible if the callbacks are NSObjects instead of blocks, and in -[dealloc] they tell JS to free the corresponding JS closure. My sense is this feature is desirable but the implementation might feel a bit sketchy. Also building it on Android would require a different bag of tricks but might be possible with WeakReferences or finalize()."}}