Skip to content

Commit 45dd09e

Browse files
ChumpChiefMarioJGMsoft
authored andcommitted
Remove closeAndGetPendingLocalState (microsoft#25091)
1 parent 4fde1b2 commit 45dd09e

File tree

19 files changed

+115
-125
lines changed

19 files changed

+115
-125
lines changed

experimental/dds/tree/src/test/utilities/TestUtilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ export async function withContainerOffline<TReturn>(
695695
await provider.ensureSynchronized();
696696
await provider.opProcessingController.pauseProcessing(container);
697697
const actionReturn = action();
698-
const pendingLocalState = await container.closeAndGetPendingLocalState?.();
698+
const pendingLocalState = await container.getPendingLocalState?.();
699+
container.close();
699700
assert(pendingLocalState !== undefined, 0x726 /* pendingLocalState should be defined */);
700701
return { actionReturn, pendingLocalState };
701702
}

packages/dds/tree/src/test/shared-tree/sharedTree.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,8 @@ describe("SharedTree", () => {
17421742
await provider.opProcessingController.pauseProcessing(pausedContainer);
17431743
pausedTree.root.insertAt(1, "b");
17441744
pausedTree.root.insertAt(2, "c");
1745-
const pendingOps = await pausedContainer.closeAndGetPendingLocalState?.();
1745+
const pendingOps = await pausedContainer.getPendingLocalState?.();
1746+
pausedContainer.close();
17461747
provider.opProcessingController.resumeProcessing();
17471748

17481749
const otherLoadedView = provider.trees[1].viewWith(
@@ -2054,7 +2055,8 @@ describe("SharedTree", () => {
20542055
}),
20552056
);
20562057
pausedView.initialize([]);
2057-
const pendingOps = await pausedContainer.closeAndGetPendingLocalState?.();
2058+
const pendingOps = await pausedContainer.getPendingLocalState?.();
2059+
pausedContainer.close();
20582060
provider.opProcessingController.resumeProcessing();
20592061

20602062
const loadedContainer = await provider.loadTestContainer(

packages/loader/container-loader/src/container.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import type {
2626
IFluidCodeDetails,
2727
IFluidCodeDetailsComparer,
2828
IFluidModuleWithDetails,
29-
IGetPendingLocalStateProps,
3029
IProvideFluidCodeDetailsComparer,
3130
IProvideRuntimeFactory,
3231
IRuntime,
@@ -1191,30 +1190,12 @@ export class Container
11911190
}
11921191
}
11931192

1194-
public async closeAndGetPendingLocalState(
1195-
stopBlobAttachingSignal?: AbortSignal,
1196-
): Promise<string> {
1197-
// runtime matches pending ops to successful ones by clientId and client seq num, so we need to close the
1198-
// container at the same time we get pending state, otherwise this container could reconnect and resubmit with
1199-
// a new clientId and a future container using stale pending state without the new clientId would resubmit them
1200-
const pendingState = await this.getPendingLocalStateCore({
1201-
notifyImminentClosure: true,
1202-
stopBlobAttachingSignal,
1203-
});
1204-
this.close();
1205-
return pendingState;
1206-
}
1207-
12081193
/**
12091194
* Serialize current container state required to rehydrate to the same position without dataloss.
12101195
* Note: The container must already be attached. For detached containers use {@link serialize}
12111196
* @returns stringified {@link IPendingContainerState} for the container
12121197
*/
12131198
public async getPendingLocalState(): Promise<string> {
1214-
return this.getPendingLocalStateCore({ notifyImminentClosure: false });
1215-
}
1216-
1217-
private async getPendingLocalStateCore(props: IGetPendingLocalStateProps): Promise<string> {
12181199
if (this.closed || this._disposed) {
12191200
throw new UsageError(
12201201
"Pending state cannot be retried if the container is closed or disposed",
@@ -1229,7 +1210,6 @@ export class Container
12291210
0x0d2 /* "resolved url should be valid Fluid url" */,
12301211
);
12311212
const pendingState = await this.serializedStateManager.getPendingLocalState(
1232-
props,
12331213
this.clientId,
12341214
this.runtime,
12351215
this.resolvedUrl,
@@ -1244,7 +1224,7 @@ export class Container
12441224
/**
12451225
* Serialize current container state required to rehydrate to the same position without dataloss.
12461226
* Note: The container must be detached and not closed. For attached containers use
1247-
* {@link getPendingLocalState} or {@link closeAndGetPendingLocalState}
1227+
* {@link getPendingLocalState}
12481228
* @returns stringified {@link IPendingDetachedContainerState} for the container
12491229
*/
12501230
public serialize(): string {
@@ -2586,10 +2566,4 @@ export interface IContainerExperimental extends IContainer {
25862566
* @returns serialized blob that can be passed to Loader.resolve()
25872567
*/
25882568
getPendingLocalState?(): Promise<string>;
2589-
2590-
/**
2591-
* Closes the container and returns serialized local state intended to be
2592-
* given to a newly loaded container.
2593-
*/
2594-
closeAndGetPendingLocalState?(stopBlobAttachingSignal?: AbortSignal): Promise<string>;
25952569
}

packages/loader/container-loader/src/serializedStateManager.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
*/
55

66
import { stringToBuffer } from "@fluid-internal/client-utils";
7-
import {
8-
IGetPendingLocalStateProps,
9-
IRuntime,
10-
} from "@fluidframework/container-definitions/internal";
7+
import { IRuntime } from "@fluidframework/container-definitions/internal";
118
import type {
129
IEventProvider,
1310
IEvent,
@@ -422,7 +419,6 @@ export class SerializedStateManager {
422419
* to be stored and used to rehydrate the container at a later time.
423420
*/
424421
public async getPendingLocalState(
425-
props: IGetPendingLocalStateProps,
426422
clientId: string | undefined,
427423
runtime: Pick<IRuntime, "getPendingLocalState">,
428424
resolvedUrl: IResolvedUrl,
@@ -432,9 +428,9 @@ export class SerializedStateManager {
432428
{
433429
eventName: "getPendingLocalState",
434430
details: {
435-
notifyImminentClosure: props.notifyImminentClosure,
436-
sessionExpiryTimerStarted: props.sessionExpiryTimerStarted,
437-
snapshotSequenceNumber: props.snapshotSequenceNumber,
431+
notifyImminentClosure: false,
432+
sessionExpiryTimerStarted: undefined,
433+
snapshotSequenceNumber: undefined,
438434
processedOpsSize: this.processedOps.length,
439435
},
440436
clientId,
@@ -445,7 +441,7 @@ export class SerializedStateManager {
445441
}
446442
assert(this.snapshot !== undefined, 0x8e5 /* no base data */);
447443
const pendingRuntimeState = await runtime.getPendingLocalState({
448-
...props,
444+
notifyImminentClosure: false,
449445
snapshotSequenceNumber: this.snapshot.snapshotSequenceNumber,
450446
sessionExpiryTimerStarted: this.snapshot.snapshotFetchedTime,
451447
});

packages/loader/container-loader/src/test/serializedStateManager.spec.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ describe("serializedStateManager", () => {
198198
await assert.rejects(
199199
async () =>
200200
serializedStateManager.getPendingLocalState(
201-
{
202-
notifyImminentClosure: false,
203-
},
204201
"clientId",
205202
new MockRuntime(),
206203
resolvedUrl,
@@ -231,7 +228,6 @@ describe("serializedStateManager", () => {
231228
},
232229
});
233230
await serializedStateManager.getPendingLocalState(
234-
{ notifyImminentClosure: false },
235231
"clientId",
236232
new MockRuntime(),
237233
resolvedUrl,
@@ -257,7 +253,6 @@ describe("serializedStateManager", () => {
257253
assert(baseSnapshot);
258254
assert.strictEqual(version, undefined);
259255
const state = await serializedStateManager.getPendingLocalState(
260-
{ notifyImminentClosure: false },
261256
"clientId",
262257
new MockRuntime(),
263258
resolvedUrl,
@@ -282,7 +277,6 @@ describe("serializedStateManager", () => {
282277
assert.strictEqual(version?.id, "fromStorage");
283278
assert.strictEqual(version.treeId, "fromStorage");
284279
const state = await serializedStateManager.getPendingLocalState(
285-
{ notifyImminentClosure: false },
286280
"clientId",
287281
new MockRuntime(),
288282
resolvedUrl,
@@ -333,7 +327,6 @@ describe("serializedStateManager", () => {
333327
// getting pending state without waiting for fetching new snapshot.
334328
assert.strictEqual(getLatestSnapshotInfoP.isCompleted, false);
335329
const state = await serializedStateManager.getPendingLocalState(
336-
{ notifyImminentClosure: false },
337330
"clientId",
338331
new MockRuntime(),
339332
resolvedUrl,
@@ -384,7 +377,6 @@ describe("serializedStateManager", () => {
384377
}
385378

386379
const state = await serializedStateManager.getPendingLocalState(
387-
{ notifyImminentClosure: false },
388380
"clientId",
389381
new MockRuntime(),
390382
resolvedUrl,
@@ -442,7 +434,6 @@ describe("serializedStateManager", () => {
442434
await serializedStateManager.refreshSnapshotP;
443435

444436
const state = await serializedStateManager.getPendingLocalState(
445-
{ notifyImminentClosure: false },
446437
"clientId",
447438
new MockRuntime(),
448439
resolvedUrl,
@@ -498,7 +489,6 @@ describe("serializedStateManager", () => {
498489
},
499490
]);
500491
const state = await serializedStateManager.getPendingLocalState(
501-
{ notifyImminentClosure: false },
502492
"clientId",
503493
new MockRuntime(),
504494
resolvedUrl,
@@ -559,7 +549,6 @@ describe("serializedStateManager", () => {
559549
},
560550
]);
561551
const state = await serializedStateManager.getPendingLocalState(
562-
{ notifyImminentClosure: false },
563552
"clientId",
564553
new MockRuntime(),
565554
resolvedUrl,
@@ -608,7 +597,6 @@ describe("serializedStateManager", () => {
608597
eventEmitter.emit("saved");
609598
}
610599
const state = await serializedStateManager.getPendingLocalState(
611-
{ notifyImminentClosure: false },
612600
"clientId",
613601
new MockRuntime(),
614602
resolvedUrl,
@@ -655,7 +643,6 @@ describe("serializedStateManager", () => {
655643
await serializedStateManager.fetchSnapshot(undefined);
656644
await serializedStateManager.refreshSnapshotP;
657645
const state = await serializedStateManager.getPendingLocalState(
658-
{ notifyImminentClosure: false },
659646
"clientId",
660647
new MockRuntime(),
661648
resolvedUrl,
@@ -710,7 +697,6 @@ describe("serializedStateManager", () => {
710697
}
711698

712699
const state = await serializedStateManager.getPendingLocalState(
713-
{ notifyImminentClosure: false },
714700
"clientId",
715701
new MockRuntime(),
716702
resolvedUrl,
@@ -777,7 +763,6 @@ describe("serializedStateManager", () => {
777763
}
778764

779765
const state = await serializedStateManager.getPendingLocalState(
780-
{ notifyImminentClosure: false },
781766
"clientId",
782767
new MockRuntime(),
783768
resolvedUrl,
@@ -815,7 +800,6 @@ describe("serializedStateManager", () => {
815800
},
816801
};
817802
const state = await serializedStateManager.getPendingLocalState(
818-
{ notifyImminentClosure: false },
819803
"clientId",
820804
mockRuntime,
821805
resolvedUrl,
@@ -858,7 +842,6 @@ describe("serializedStateManager", () => {
858842
},
859843
};
860844
const state = await serializedStateManager.getPendingLocalState(
861-
{ notifyImminentClosure: false },
862845
"clientId",
863846
mockRuntime,
864847
resolvedUrl,
@@ -913,7 +896,6 @@ describe("serializedStateManager", () => {
913896
},
914897
};
915898
const state = await serializedStateManager.getPendingLocalState(
916-
{ notifyImminentClosure: false },
917899
"clientId",
918900
mockRuntime,
919901
resolvedUrl,
@@ -957,7 +939,6 @@ describe("serializedStateManager", () => {
957939
): Promise<void> => {
958940
// pending state validation
959941
const state = await serializedStateManager.getPendingLocalState(
960-
{ notifyImminentClosure: false },
961942
"clientId",
962943
new MockRuntime(),
963944
resolvedUrl,

packages/runtime/container-runtime/src/containerRuntime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5056,7 +5056,7 @@ export class ContainerRuntime
50565056
};
50575057

50585058
// Flush pending batch.
5059-
// getPendingLocalState() is only exposed through Container.closeAndGetPendingLocalState(), so it's safe
5059+
// getPendingLocalState() is only exposed through Container.getPendingLocalState(), so it's safe
50605060
// to close current batch.
50615061
this.flush();
50625062

packages/test/test-end-to-end-tests/src/test/container.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describeCompat("Container", "NoCompat", (getTestObjectProvider) => {
324324
assert.strictEqual(runCount, 1);
325325
});
326326

327-
it("closeAndGetPendingLocalState() called on container", async () => {
327+
it("getPendingLocalState() called on container", async () => {
328328
const configProvider = (settings: Record<string, ConfigTypes>): IConfigProviderBase => ({
329329
getRawConfig: (name: string): ConfigTypes => settings[name],
330330
});
@@ -348,7 +348,8 @@ describeCompat("Container", "NoCompat", (getTestObjectProvider) => {
348348

349349
const container: IContainerExperimental =
350350
await localTestObjectProvider.makeTestContainer(testContainerConfig);
351-
const pendingString = await container.closeAndGetPendingLocalState?.();
351+
const pendingString = await container.getPendingLocalState?.();
352+
container.close();
352353
assert.ok(pendingString);
353354
const pendingLocalState: { url?: string } = JSON.parse(pendingString);
354355
assert.strictEqual(container.closed, true);

packages/test/test-end-to-end-tests/src/test/data-virtualization/groupIdOffline.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ describeCompat("GroupId offline", "NoCompat", (getTestObjectProvider, apis) => {
143143

144144
// Get Pending state and close
145145
assert(
146-
container.closeAndGetPendingLocalState !== undefined,
147-
"Test can't run without closeAndGetPendingLocalState",
146+
container.getPendingLocalState !== undefined,
147+
"Test can't run without getPendingLocalState",
148148
);
149-
const pendingState = await container.closeAndGetPendingLocalState();
149+
const pendingState = await container.getPendingLocalState();
150+
container.close();
150151

151152
// Load from the pending state
152153
const container3 = await provider.loadContainer(
@@ -234,8 +235,9 @@ describeCompat("GroupId offline", "NoCompat", (getTestObjectProvider, apis) => {
234235
dataObjectA2._root.set("A2", "A2");
235236

236237
// Get Pending state and close
237-
assert(container2.closeAndGetPendingLocalState !== undefined, "Missing method!");
238-
const pendingState = await container2.closeAndGetPendingLocalState();
238+
assert(container2.getPendingLocalState !== undefined, "Missing method!");
239+
const pendingState = await container2.getPendingLocalState();
240+
container2.close();
239241

240242
// Load from the pending state
241243
const container3 = await provider.loadContainer(
@@ -356,8 +358,9 @@ describeCompat("GroupId offline", "NoCompat", (getTestObjectProvider, apis) => {
356358
dataObjectB2._root.set("B2", "B2");
357359

358360
// Get Pending state and close
359-
assert(container2.closeAndGetPendingLocalState !== undefined, "Missing method!");
360-
const pendingState = await container2.closeAndGetPendingLocalState();
361+
assert(container2.getPendingLocalState !== undefined, "Missing method!");
362+
const pendingState = await container2.getPendingLocalState();
363+
container2.close();
361364

362365
// Load from the pending state
363366
const container3 = await provider.loadContainer(

packages/test/test-end-to-end-tests/src/test/data-virtualization/initialSequenceNumberAndStashedOps.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ describeCompat(
5959
mainObject._root.set("4", "4");
6060

6161
// Generate pending state
62-
const pendingState = await container.closeAndGetPendingLocalState?.();
62+
const pendingState = await container.getPendingLocalState?.();
63+
container.close();
6364

6465
// Load from the pending state
6566
const container2 = (await provider.loadTestContainer(

packages/test/test-end-to-end-tests/src/test/data-virtualization/noGroupIdOfflineFlow.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ describeCompat("Offline Attach Ops", "NoCompat", (getTestObjectProvider, apis) =
8585
const childObject = await dataObjectFactory.createInstance(mainObject.containerRuntime);
8686
mainObject._root.set("testObject2", childObject.handle);
8787

88-
const serializedState = await container.closeAndGetPendingLocalState?.();
88+
const serializedState = await container.getPendingLocalState?.();
89+
container.close();
8990
assert(serializedState !== undefined, "serializedState should not be undefined");
9091

9192
// This should not hang

0 commit comments

Comments
 (0)