Skip to content

Commit 4ebfb3d

Browse files
Revert "Try downlevelIteration"
This reverts commit b04f425.
1 parent b04f425 commit 4ebfb3d

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

packages/firestore/src/core/sync_engine.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
398398
try {
399399
const changes = await this.localStore.applyRemoteEvent(remoteEvent);
400400
// Update `receivedDocument` as appropriate for any limbo targets.
401-
for (const [targetId, targetChange] of remoteEvent.targetChanges) {
401+
remoteEvent.targetChanges.forEach((targetChange, targetId) => {
402402
const limboResolution = this.limboResolutionsByTarget.get(targetId);
403403
if (limboResolution) {
404404
// Since this is a limbo resolution lookup, it's for a single document
@@ -427,7 +427,7 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
427427
// This was probably just a CURRENT targetChange or similar.
428428
}
429429
}
430-
}
430+
});
431431
await this.emitNewSnapsAndNotifyLocalStore(changes, remoteEvent);
432432
} catch (error) {
433433
await ignoreIfPrimaryLeaseLoss(error);
@@ -643,11 +643,11 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
643643

644644
/** Reject all outstanding callbacks waiting for pending writes to complete. */
645645
private rejectOutstandingPendingWritesCallbacks(errorMessage: string): void {
646-
for (const [_, callbacks] of this.pendingWritesCallbacks) {
647-
for (const callback of callbacks) {
646+
this.pendingWritesCallbacks.forEach(callbacks => {
647+
callbacks.forEach(callback => {
648648
callback.reject(new FirestoreError(Code.CANCELLED, errorMessage));
649-
}
650-
}
649+
});
650+
});
651651

652652
this.pendingWritesCallbacks.clear();
653653
}
@@ -913,18 +913,22 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
913913

914914
const activeTargets: TargetId[] = [];
915915

916-
for (const [targetId] of this.queriesByTarget) {
916+
let p = Promise.resolve();
917+
this.queriesByTarget.forEach((_, targetId) => {
917918
if (this.sharedClientState.isLocalQueryTarget(targetId)) {
918919
activeTargets.push(targetId);
919920
} else {
920-
await this.removeAndCleanupTarget(targetId);
921-
await this.localStore.releaseTarget(
922-
targetId,
923-
/*keepPersistedTargetData=*/ true
924-
);
921+
p = p.then(() => {
922+
this.removeAndCleanupTarget(targetId);
923+
return this.localStore.releaseTarget(
924+
targetId,
925+
/*keepPersistedTargetData=*/ true
926+
);
927+
});
925928
}
926929
this.remoteStore.unlisten(targetId);
927-
}
930+
});
931+
await p;
928932

929933
await this.synchronizeQueryViewsAndRaiseSnapshots(activeTargets);
930934
this.resetLimboDocuments();
@@ -934,9 +938,9 @@ export class SyncEngine implements RemoteSyncer, SharedClientStateSyncer {
934938

935939
// PORTING NOTE: Multi-tab only.
936940
private resetLimboDocuments(): void {
937-
for (const [targetId] of this.limboResolutionsByTarget) {
941+
this.limboResolutionsByTarget.forEach((_, targetId) => {
938942
this.remoteStore.unlisten(targetId);
939-
}
943+
});
940944
this.limboDocumentRefs.removeAllReferences();
941945
this.limboResolutionsByTarget = new Map<TargetId, LimboResolution>();
942946
this.limboTargetsByKey = new SortedMap<DocumentKey, TargetId>(

packages/firestore/src/local/local_store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,10 @@ export class LocalStore {
519519
newTargetDataByTargetMap = this.targetDataByTarget;
520520

521521
const promises = [] as Array<PersistencePromise<void>>;
522-
for (const [targetId, change] of remoteEvent.targetChanges) {
522+
remoteEvent.targetChanges.forEach((change, targetId) => {
523523
const oldTargetData = newTargetDataByTargetMap.get(targetId);
524524
if (!oldTargetData) {
525-
continue;
525+
return;
526526
}
527527

528528
// Only update the remote keys if the target is still active. This
@@ -565,7 +565,7 @@ export class LocalStore {
565565
);
566566
}
567567
}
568-
}
568+
});
569569

570570
let changedDocs = maybeDocumentMap();
571571
let updatedKeys = documentKeySet();

packages/firestore/src/model/field_value.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class ObjectValueBuilder {
256256
{ ...existingValue.mapValue.fields }
257257
: {};
258258

259-
for (const [pathSegment, value] of currentOverlays) {
259+
currentOverlays.forEach((value, pathSegment) => {
260260
if (value instanceof Map) {
261261
const nested = this.applyOverlay(currentPath.child(pathSegment), value);
262262
if (nested != null) {
@@ -270,7 +270,7 @@ export class ObjectValueBuilder {
270270
delete resultAtPath[pathSegment];
271271
modified = true;
272272
}
273-
}
273+
});
274274

275275
return modified ? { mapValue: { fields: resultAtPath } } : null;
276276
}

packages/firestore/src/remote/remote_store.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ export class RemoteStore implements TargetMetadataProvider {
343343
}
344344

345345
private async onWatchStreamOpen(): Promise<void> {
346-
for (const [_, targetData] of this.listenTargets) {
346+
this.listenTargets.forEach((targetData, targetId) => {
347347
this.sendWatchRequest(targetData);
348-
}
348+
});
349349
}
350350

351351
private async onWatchStreamClose(error?: FirestoreError): Promise<void> {
@@ -428,7 +428,7 @@ export class RemoteStore implements TargetMetadataProvider {
428428

429429
// Update in-memory resume tokens. LocalStore will update the
430430
// persistent view of these when applying the completed RemoteEvent.
431-
for (const [targetId, change] of remoteEvent.targetChanges) {
431+
remoteEvent.targetChanges.forEach((change, targetId) => {
432432
if (change.resumeToken.approximateByteSize() > 0) {
433433
const targetData = this.listenTargets.get(targetId);
434434
// A watched target might have been removed already.
@@ -439,7 +439,7 @@ export class RemoteStore implements TargetMetadataProvider {
439439
);
440440
}
441441
}
442-
}
442+
});
443443

444444
// Re-establish listens for the targets that have been invalidated by
445445
// existence filter mismatches.

packages/firestore/src/remote/watch_change.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ export class WatchChangeAggregator {
422422
createRemoteEvent(snapshotVersion: SnapshotVersion): RemoteEvent {
423423
const targetChanges = new Map<TargetId, TargetChange>();
424424

425-
for (const [targetId, targetState] of this.targetStates) {
425+
this.targetStates.forEach((targetState, targetId) => {
426426
const targetData = this.targetDataForActiveTarget(targetId);
427427
if (targetData) {
428428
if (targetState.current && targetData.target.isDocumentQuery()) {
@@ -453,7 +453,7 @@ export class WatchChangeAggregator {
453453
targetState.clearPendingChanges();
454454
}
455455
}
456-
}
456+
});
457457

458458
let resolvedLimboDocuments = documentKeySet();
459459

packages/firestore/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"extends": "../../config/tsconfig.base.json",
33
"compilerOptions": {
4-
"outDir": "dist",
5-
"downlevelIteration": true,
6-
"importHelpers": true
4+
"outDir": "dist"
75
},
86
"exclude": [
97
"dist/**/*"

0 commit comments

Comments
 (0)