Summary: It's common for responses to be completely missing in the network inspector. This is because they are larger than can be serialized in one go on some devices, so we drop all messages larger than 1MB. This changes the android client to send large responses in individually serialized batches. This way we avoid running out of memory and can still send arbitrarily large payloads. Changelog: Android network inspector can now handle responses large than 1MB. Reviewed By: passy Differential Revision: D22999905 fbshipit-source-id: ff4eb8fa72a7e42ea90d12ffe0f20c6d1e58b7e5
29 lines
802 B
TypeScript
29 lines
802 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {TextDecoder} from 'util';
|
|
|
|
export function combineBase64Chunks(chunks: string[]): string {
|
|
const byteArray = chunks.map(
|
|
(b64Chunk) =>
|
|
Uint8Array.from(atob(b64Chunk), (c) => c.charCodeAt(0)).buffer,
|
|
);
|
|
const size = byteArray
|
|
.map((b) => b.byteLength)
|
|
.reduce((prev, curr) => prev + curr, 0);
|
|
const buffer = new Uint8Array(size);
|
|
let offset = 0;
|
|
for (let i = 0; i < byteArray.length; i++) {
|
|
buffer.set(new Uint8Array(byteArray[i]), offset);
|
|
offset += byteArray[i].byteLength;
|
|
}
|
|
const data = new TextDecoder('utf-8').decode(buffer);
|
|
return data;
|
|
}
|