Skip to content

Commit 2267379

Browse files
Merge 997499e into 629919e
2 parents 629919e + 997499e commit 2267379

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

.changeset/sharp-dingos-admire.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/firestore": patch
3+
---
4+
5+
Re-enable useFetchStreams with the latest WebChannel implementation. This reduces the memory usage of WebChannel.

packages/firestore/src/platform/browser/webchannel_connection.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
EventTarget,
2828
StatEvent,
2929
Event,
30-
FetchXmlHttpFactory,
3130
Stat
3231
} from '@firebase/webchannel-wrapper/webchannel-blob';
3332

@@ -209,7 +208,7 @@ export class WebChannelConnection extends RestConnection {
209208
}
210209

211210
if (this.useFetchStreams) {
212-
request.xmlHttpFactory = new FetchXmlHttpFactory({});
211+
request.useFetchStreams = true;
213212
}
214213

215214
this.modifyHeadersForRequest(

packages/firestore/test/integration/api/query.test.ts

+45
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,51 @@ apiDescribe('Queries', persistence => {
22172217
});
22182218
}
22192219
).timeout('90s');
2220+
2221+
it('can query large documents with multi-byte character strings', () => {
2222+
function randomMultiByteCharString(length: number): string {
2223+
const charCodes: number[] = [];
2224+
2225+
for (let i = 0; i < length; i++) {
2226+
charCodes.push(randInt(1, 65535));
2227+
}
2228+
2229+
return String.fromCharCode(...charCodes);
2230+
}
2231+
2232+
function randInt(min: number, max: number): number {
2233+
const scale = max - min + 1;
2234+
return Math.floor(Math.random() * scale);
2235+
}
2236+
2237+
let bigString = randomMultiByteCharString(10000);
2238+
2239+
// Encode and decode `bigString` to/from UTF-8 to
2240+
// ensure that any transformations applied during
2241+
// UTF-8 encoding are applied equally to the expected
2242+
// and actual results.
2243+
const textEncoder = new TextEncoder();
2244+
const textDecoder = new TextDecoder();
2245+
bigString = textDecoder.decode(textEncoder.encode(bigString));
2246+
2247+
const doc = {
2248+
field: bigString
2249+
};
2250+
2251+
expect(bigString).to.deep.equal(bigString);
2252+
2253+
return withTestCollection(
2254+
persistence,
2255+
{ 1: doc },
2256+
async collectionReference => {
2257+
const querySnap = await getDocs(collectionReference);
2258+
expect(querySnap.size).to.equal(1);
2259+
2260+
const fieldValue = querySnap.docs[0].get('field');
2261+
expect(fieldValue).to.deep.equal(bigString);
2262+
}
2263+
);
2264+
});
22202265
});
22212266

22222267
apiDescribe('Hanging query issue - #7652', persistence => {

0 commit comments

Comments
 (0)