Skip to content

ReferenceError: Can't find variable: ArrayBuffer #871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neeravmehta opened this issue Jan 12, 2016 · 13 comments
Closed

ReferenceError: Can't find variable: ArrayBuffer #871

neeravmehta opened this issue Jan 12, 2016 · 13 comments
Labels
guidance Question that needs advice or information.

Comments

@neeravmehta
Copy link

You need to check for existance of ArrayBuffer before using it. this is happening in hash function for the crypto module. Specifically line 4270 in a development build with only firehose, cognito and mobile analytics services. Search for
data.buffer instanceof ArrayBuffer

@chrisradek
Copy link
Contributor

@neeravmehta
Can you tell me what environment ArrayBuffer isn't defined in?

@neeravmehta
Copy link
Author

Our environment is a javascript/HTML5 mobile app, it uses an older version of webkit compiler.

@chrisradek
Copy link
Contributor

I can add that check for ArrayBuffer to the SDK. I'm not sure that will be enough to fully resolve the issue you're seeing though. Have you tried adding that check and verified it works for your use case?

Just for reference, here's a list of the currently supported browsers:
http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-intro.html

@neeravmehta
Copy link
Author

Thanks ! That would be great!
Yeah I have it working with the ArrayBuffer check.In fact it is already being used with the check elsewhere in your codebase. How long does it take for this makes it to your sdk builder site?
Although I am running into a networking error related to credentials, digging deeper to find out what is going on.

chrisradek added a commit that referenced this issue Jan 12, 2016
chrisradek added a commit that referenced this issue Jan 12, 2016
chrisradek added a commit that referenced this issue Jan 12, 2016
@chrisradek
Copy link
Contributor

@neeravmehta
I included the check with the just released v2.2.29 of the SDK. I'm going to close this issue, but feel free to open a new one if you find your networking issues are related to the SDK.

@neeravmehta
Copy link
Author

@chrisradek
Hi, I checked it in latest version, the check still causes error. Probably javascript tries to think of it as a variable, that is not found. Here is the exact error I am getting "Can't find variable: ArrayBuffer"

Here is the check that fixed it for me
if (util.isBrowser() && typeof ArrayBuffer !== "undefined" && data && data.buffer instanceof ArrayBuffer) isBuffer = true;
instead of
if (util.isBrowser() && ArrayBuffer && data && data.buffer instanceof ArrayBuffer) isBuffer = true;

@chrisradek
Copy link
Contributor

What is ArrayBuffer when you hit that line? Just checking for ArrayBuffer should return a falsey value if it is undefined, which is also what your check is doing.

@neeravmehta
Copy link
Author

Unfortunately I cannot debug our platform, so i cannot tell you the exact value for ArrayBuffer. But from what I understand it does not know what ArrayBuffer is, hence best guesses it to a variable , that is not defined and throws an error when it sees it being used. This thread helped me understand it

http://stackoverflow.com/questions/3390396/how-to-check-for-undefined-in-javascript

@jeskew
Copy link
Contributor

jeskew commented Jan 13, 2016

@neeravmehta Is the application running on Appcelerator?

@AdityaManohar
Copy link
Contributor

@neeravmehta it looks like you may be using a version of JavaScriptCore that is bundling an unsupported version of WebKit.

As @chrisradek mentioned, the linked patch should address any undefined identifiers on a standards compliant JavaScript engine. Even if this patch were to be changed to explicitly check for undefined, there are other issues that you may run into with native JavaScript API support.

There have been other issues reported when using using Appcelerator and Appcelerator like environments that use an outdated version of JavaScriptCore. See #784

@neeravmehta
Copy link
Author

@jeskew While it is'nt Appcelerator in particulr but our platform pretty much does the same thing, and it does use an older version of Webkit.

@AdityaManohar Thanks for the update, I have already run into some issues because of this, I am trying to see if I can get this to work as that will reduce our effort significantly. Our other options are to incorporate both iOS and Android sdk for respective environments, or use REST APIs(where we end up redoing a lot of things that aws-sdk does for us)

I am not sure if this is the right forum for this but will just put is out there, does AWS firehose have REST APIs that we can access to put records?

@AdityaManohar
Copy link
Contributor

@neeravmehta
AWS Kinesis Firehose does have a public REST API that you can use but you may still need the SDK to sign requests (or some other equivalent Signature Version 4 signer). Here is the API documentation for AWS Kinesis Firehose.

Your other alternative is to try and use Amazon API Gateway to proxy requests to AWS Kinesis Firehose. This becomes trivially simple if you are using unauthenticated roles to put records to Kinesis Firehose.

Let me know if the helps. Here is a comment that I posted on using API Gateway with CloudSearch - the same concepts apply.

chrisradek added a commit that referenced this issue Jan 14, 2016
@srchase srchase added guidance Question that needs advice or information. and removed Question labels Jan 4, 2019
@lock
Copy link

lock bot commented Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

5 participants