{"action":"created","issue":{"url":"https://api.github.com/repos/awslabs/aws-sdk-react-native/issues/3","repository_url":"https://api.github.com/repos/awslabs/aws-sdk-react-native","labels_url":"https://api.github.com/repos/awslabs/aws-sdk-react-native/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/awslabs/aws-sdk-react-native/issues/3/comments","events_url":"https://api.github.com/repos/awslabs/aws-sdk-react-native/issues/3/events","html_url":"https://github.com/awslabs/aws-sdk-react-native/issues/3","id":174489312,"number":3,"title":"Core project bug - Cognito RCTJSONStringify errors (NSTaggedDate, __NSMallocBlock__)","user":{"login":"willks","id":8967148,"avatar_url":"https://avatars.githubusercontent.com/u/8967148?v=3","gravatar_id":"","url":"https://api.github.com/users/willks","html_url":"https://github.com/willks","followers_url":"https://api.github.com/users/willks/followers","following_url":"https://api.github.com/users/willks/following{/other_user}","gists_url":"https://api.github.com/users/willks/gists{/gist_id}","starred_url":"https://api.github.com/users/willks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willks/subscriptions","organizations_url":"https://api.github.com/users/willks/orgs","repos_url":"https://api.github.com/users/willks/repos","events_url":"https://api.github.com/users/willks/events{/privacy}","received_events_url":"https://api.github.com/users/willks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-09-01T10:28:33Z","updated_at":"2016-09-10T07:56:03Z","closed_at":null,"body":"Hi,\r\n  I've banged my head for a few hours on this issue when integrating with my project - and it seems that the reference example project is also broken. The issue is this block in the example/index.js\r\n\r\n```\r\nasync function getCredAndID(){\r\n      try{\r\n        var variable = await AWSCognitoCredentials.getCredentialsAsync();\r\n        that.setState({AccessKey:variable[\"AccessKey\"],SecretKey:variable[\"SecretKey\"],\r\n        SessionKey:variable[\"SessionKey\"],Expiration:variable[\"Expiration\"].toString()});\r\n        variable = await AWSCognitoCredentials.getIdentityIDAsync();\r\n        that.setState({identityID:variable.identityid});\r\n      }catch(e){\r\n        console.log(\"Error: \" + e)\r\n        return;\r\n      }\r\n    }\r\n```\r\n\r\nSpecifically, the line:\r\n\r\n`var variable = await AWSCognitoCredentials.getCredentialsAsync();`\r\n\r\nAlways results in an error as follows:\r\n\r\n<img width=\"465\" alt=\"screen shot 2016-09-01 at 8 19 59 pm\" src=\"https://cloud.githubusercontent.com/assets/8967148/18164087/7de73d4c-7081-11e6-90cc-0fc38381085d.png\">\r\n\r\n\r\nAnd the error in plain text:\r\n\r\n```\r\n2016-09-01 20:17:29.399 example[95700:996058] *** -[NSLock lock]: deadlock (<NSLock: 0x7f87ab57c3b0> '(null)')\r\n2016-09-01 20:17:29.399 example[95700:996058] *** Break on _NSLockError() to debug.\r\n2016-09-01 20:17:29.400 [error][tid:com.facebook.react.WebSocketExecutor][RCTUtils.m:80] RCTJSONStringify() encountered the following error: Invalid type in JSON write (__NSMallocBlock__)\r\n```\r\n\r\nLooks like the bundled library is trying to send an event with a \"block\" payload. Then, you have another bug, which I found only when I modified the AWSCognitoCredentials.m - you can't do this in react native:\r\n\r\n```\r\nRCT_EXPORT_METHOD(getCredentialsAsync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){\r\n    [[credentialProvider credentials] continueWithBlock:^id(AWSTask *task) {\r\n        if (task.exception){\r\n            dispatch_async(dispatch_get_main_queue(), ^{\r\n                @throw [NSException exceptionWithName:task.exception.name reason:task.exception.reason userInfo:task.exception.userInfo];\r\n            });\r\n        }\r\n        if (task.error) {\r\n            reject([NSString stringWithFormat:@\"%ld\",task.error.code],task.error.description,task.error);\r\n        }\r\n        else {\r\n            AWSCredentials *cred = (AWSCredentials*) task.result;\r\n            NSDictionary *dict = @{@\"AccessKey\":cred.accessKey,@\"SecretKey\":cred.secretKey,@\"SessionKey\":cred.sessionKey,@\"Expiration\":cred.expiration};\r\n            resolve(dict);\r\n        }\r\n        return nil;\r\n    }];\r\n}\r\n```\r\n\r\nYou are sending an NSTaggedDate (NSDate) here: cred.expiration, which is not serializable by the RCT Bridge! I never got it working, (the example) - otherwise I would have submitted a pull request but I'm a green ObjC dev. \r\n\r\nI really hope that it's just me and that the underlying framework is not buggy - as I really need this project :)\r\n\r\nThanks\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/awslabs/aws-sdk-react-native/issues/comments/246098140","html_url":"https://github.com/awslabs/aws-sdk-react-native/issues/3#issuecomment-246098140","issue_url":"https://api.github.com/repos/awslabs/aws-sdk-react-native/issues/3","id":246098140,"user":{"login":"willks","id":8967148,"avatar_url":"https://avatars.githubusercontent.com/u/8967148?v=3","gravatar_id":"","url":"https://api.github.com/users/willks","html_url":"https://github.com/willks","followers_url":"https://api.github.com/users/willks/followers","following_url":"https://api.github.com/users/willks/following{/other_user}","gists_url":"https://api.github.com/users/willks/gists{/gist_id}","starred_url":"https://api.github.com/users/willks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willks/subscriptions","organizations_url":"https://api.github.com/users/willks/orgs","repos_url":"https://api.github.com/users/willks/repos","events_url":"https://api.github.com/users/willks/events{/privacy}","received_events_url":"https://api.github.com/users/willks/received_events","type":"User","site_admin":false},"created_at":"2016-09-10T07:56:03Z","updated_at":"2016-09-10T07:56:03Z","body":"Any updates on this issue? "}}
{"actor":{"display_login":"willks"}}