mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1632722 - IO.read hits 'too many arguments' r=remote-protocol-reviewers,jgraham
Differential Revision: https://phabricator.services.mozilla.com/D86262
This commit is contained in:
parent
f5b18fe910
commit
e9022983f1
@ -101,8 +101,17 @@ class IO extends Domain {
|
||||
|
||||
const bytes = await stream.read(chunkSize);
|
||||
// Each UCS2 character has an upper byte of 0 and a lower byte matching
|
||||
// the binary data
|
||||
const data = btoa(String.fromCharCode.apply(null, bytes));
|
||||
// the binary data. Using a loop here prevents us from hitting the browser's
|
||||
// internal `arguments.length` limit.
|
||||
const ARGS_MAX = 262144;
|
||||
const stringData = [];
|
||||
for (let i = 0; i < bytes.length; i += ARGS_MAX) {
|
||||
let argsChunk = Math.min(bytes.length, i + ARGS_MAX);
|
||||
stringData.push(
|
||||
String.fromCharCode.apply(null, bytes.slice(i, argsChunk))
|
||||
);
|
||||
}
|
||||
const data = btoa(stringData.join(""));
|
||||
|
||||
return {
|
||||
data,
|
||||
|
Loading…
Reference in New Issue
Block a user