Skip to content
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

RangeError: Maximum call stack size exceeded. #137

Closed
smakinson opened this issue Dec 4, 2014 · 6 comments
Closed

RangeError: Maximum call stack size exceeded. #137

smakinson opened this issue Dec 4, 2014 · 6 comments

Comments

@smakinson
Copy link

I am using your lib to upload images to github and I came across this error "RangeError: Maximum call stack size exceeded." in chrome & safari when uploading. I found this discussion:

http://stackoverflow.com/questions/3195865/converting-byte-array-to-string-in-javascript

and I tried the suggestion in lovasoa's toBinString function and changed the code around line 366 from:

content = {
"content": btoa(String.fromCharCode.apply(null, new Uint8Array(content))),
"encoding": "base64"
};

to

var uarr = new Uint8Array(content);
var strings = [], chunksize = 0xffff;
var len = uarr.length;

// There is a maximum stack size. We cannot call String.fromCharCode with as many arguments as we want
for (var i = 0; i * chunksize < len; i++){
strings.push(String.fromCharCode.apply(null, uarr.subarray(i * chunksize, (i + 1) * chunksize)));
}

content = {
"content": btoa(strings.join('')),
"encoding": "base64"
};

It seems to work now. I have not done tons of testing, but I thought I'd file a bug if someone has some time to check it out.

@RouR
Copy link

RouR commented Jul 23, 2015

thanks!

@aendra-rininsland
Copy link
Member

Interesting — @smakinson, would you mind please doing a pull request and adding a test? Would be most appreciated!

Marking as bug for 0.10.7 release.

@AurelioDeRosa
Copy link
Member

I haven't seen this issue and it might be interesting to see if the solution I provide in this article solves it.

@aendra-rininsland aendra-rininsland modified the milestones: v0.10.8, v0.10.7 Oct 30, 2015
@aendra-rininsland
Copy link
Member

Bumping to 0.10.8, we really need to release 0.10.7.

@AurelioDeRosa
Copy link
Member

We couldn't replicate this issue, so I'm closing it. Feel free to open the issue again if the bug occurs again.

@enginzhu
Copy link

enginzhu commented Mar 7, 2016

it helps.thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants