Skip to content

Fix internal assertion encountered when testing with jsdom. #8142

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

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/hot-turkeys-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": patch
---

Fix internal assertion due to Buffer value not evaluating to instanceof Uint8Array, encountered when testing with jsdom.
10 changes: 8 additions & 2 deletions packages/firestore/src/remote/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,14 @@ export function fromBytes(
return ByteString.fromBase64String(value ? value : '');
} else {
hardAssert(
value === undefined || value instanceof Uint8Array,
'value must be undefined or Uint8Array'
value === undefined ||
// The Buffer interface extends the Uint8Array interface, however
// the Uint8ArrayConstructor is not in the prototype chain of
// Buffer, so we have to test `value instanceof Buffer` and
// `value instanceof Uint8Array`.
value instanceof Buffer ||
value instanceof Uint8Array,
'value must be undefined, Buffer, or Uint8Array'
);
return ByteString.fromUint8Array(value ? value : new Uint8Array());
}
Expand Down
Loading