Skip to content

Commit e005485

Browse files
committed
Wait for metadata to be read before move on to rest elements.
1 parent c60f8dc commit e005485

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/firestore/src/util/bundle_reader.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class BundleReader {
9696
this.reader = (this.bundleStream as ReadableStream).getReader();
9797

9898
// Read the metadata (which is the first element).
99-
this.nextElement().then(
99+
this.nextElementImpl().then(
100100
element => {
101101
if (element && element.isBundleMetadata()) {
102102
this.metadata.resolve(element.payload.metadata!);
@@ -125,6 +125,8 @@ export class BundleReader {
125125
* have reached the end of the stream.
126126
*/
127127
async nextElement(): Promise<SizedBundleElement | null> {
128+
// Makes sure metadata is read before proceeding.
129+
await this.getMetadata();
128130
return this.nextElementImpl();
129131
}
130132

0 commit comments

Comments
 (0)