Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
milaGGL committed Feb 8, 2023
1 parent 6a9e66a commit 7293289
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 0 additions & 4 deletions packages/firestore/src/core/database_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ export class DatabaseId {
other.database === this.database
);
}

canonicalString(): string {
return `projects/${this.projectId}/databases/${this.database}`;
}
}

export function databaseIdFromApp(
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/platform/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function decodeBase64(encoded: string): string {
const decoded = platform.decodeBase64(encoded);

// A quick sanity check as node and rn will not throw error if input is an
// invalid base64 string, ie, "A===".
// invalid base64 string, e.g., "A===".
const expectedEncodedLength = 4 * Math.ceil(decoded.length / 3);
if (encoded.length !== expectedEncodedLength) {
throw new Base64DecodeError('Invalid base64 string');
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/platform/browser/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function decodeBase64(encoded: string): string {
return atob(encoded);
} catch (e) {
if (e instanceof DOMException) {
throw new Base64DecodeError('Invalid base64 string');
throw new Base64DecodeError('Invalid base64 string: ' + e);
} else {
throw e;
}
Expand Down
18 changes: 11 additions & 7 deletions packages/firestore/src/remote/watch_change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,15 @@ export class WatchChangeAggregator {
normalizedBitmap = normalizeByteString(bitmap).toUint8Array();
} catch (err) {
if (err instanceof Base64DecodeError) {
logWarn('Base64 string error: ', err);
logWarn(
'Decoding the base64 bloom filter in existence filter failed (' +
err.message +
'); ignoring the bloom filter and falling back to full re-query.'
);
return false;
} else {
logWarn('Normalizing bloom filter bitmap failed: ', err);
throw err;
}
return false;
}

let bloomFilter: BloomFilter;
Expand Down Expand Up @@ -499,10 +503,10 @@ export class WatchChangeAggregator {
let removalCount = 0;

existingKeys.forEach(key => {
const documentPath =
this.metadataProvider.getDatabaseId().canonicalString() +
'/documents/' +
key.path.canonicalString();
const databaseId = this.metadataProvider.getDatabaseId();
const documentPath = `projects/${databaseId.projectId}/databases/${
databaseId.database
}/documents/${key.path.canonicalString()}`;

if (!bloomFilter.mightContain(documentPath)) {
this.removeDocumentFromTarget(targetId, key, /*updatedDocument=*/ null);
Expand Down

0 comments on commit 7293289

Please sign in to comment.