Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/actions/zipped-profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function viewProfileFromZip(
try {
// Attempt to unserialize the profile.
const profile = await unserializeProfileOfArbitraryFormat(
await file.async('uint8array'),
await file.async('arraybuffer'),
pathInZipFile
);

Expand Down
10 changes: 6 additions & 4 deletions src/profile-logic/process-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2005,10 +2005,12 @@ export async function unserializeProfileOfArbitraryFormat(
upgradeInfo: ProfileUpgradeInfo = {}
): Promise<Profile> {
try {
// We used to use `instanceof ArrayBuffer`, but this doesn't work when the
// object is constructed from an ArrayBuffer in a different context... which
// happens in our tests.
if (String(arbitraryFormat) === '[object ArrayBuffer]') {
// We use Object.prototype.toString instead of `instanceof ArrayBuffer`
// because instanceof doesn't work cross-realm (e.g. in tests), and we
// can't use String() since that serializes the full contents of a Uint8Array.
if (
Object.prototype.toString.call(arbitraryFormat) === '[object ArrayBuffer]'
) {
const arrayBuffer = arbitraryFormat as ArrayBuffer;
arbitraryFormat = new Uint8Array(arrayBuffer);
}
Expand Down
Loading