FluidFramework icon indicating copy to clipboard operation
FluidFramework copied to clipboard

AssertionError: initialMessages called twice when using SharedObjectSequence with objects containing fluid handles

Open sureshsitaula-personal opened this issue 6 years ago • 0 comments

Describe the bug

MicrosoftTeams-image

The callstack is truncated above; the rest of the callstack shows we are attempting to clone a message (and in the process end up enumerating and cloning all properties, including the 'initialMessages' getter on a DeltaConnection and this triggers the assert above):

...
cloneDeep
processMergeTreeMsg
processCore
...
processOp
processChannelOp
...
processComponentOp
...
processRemoteMessage

The message in processMergeTreeMsg is:

clientId: "baf3f954-a008-4466-b84e-8bb2ac4213bf"
clientSequenceNumber: 41
contents:
    pos1: 3
    seg:
        items: Array(1)
        0:
            component: RemoteFluidObjectHandle {absolutePath: "/4d84fb20-32ec-4038-91f0-c2edd5f7c187", routeContext: FluidHandleContext, isAttached: true}
            props: {title: "New Section", deleteable: true, titleReadOnly: false}
            __proto__: Object
            length: 1
        __proto__: Array(0)
    __proto__: Object
    type: 0
    __proto__: Object
minimumSequenceNumber: 17
referenceSequenceNumber: 18
sequenceNumber: 45
term: 1
timestamp: 1600705532572
traces: []
type: "op"
__proto__: Object

To Reproduce

This happens when I call insert on _sectionsData: SharedObjectSequence<SequenceData>

this._sectionsData.insert(this._sectionsData.getItemCount() /*pos*/, [
    { component, props: { title: 'New Section', deleteable: true, titleReadOnly: false } }
]);

with

interface SectionData {
  component: IFluidHandle;
  props: SectionProps;
}

Interestingly, this is how I initially populate the SharedObjectSequence at creation time with 3 items and it seems to be okay with a .insert like the one above:

    const sectionData = SharedObjectSequence.create<SectionData>(this.runtime);
    sectionData.insert(0 /*pos*/, [
      { component: component1, props: { title: 'Section1', titleReadOnly: true, deleteable: false } },
      { component: component2, props: { title: 'Section2', titleReadOnly: true, deleteable: false } },
      { component: component3, props: { title: 'Section3', titleReadOnly: true, deleteable: false } }
    ]);

    this.root.set<StackData>('stackData', {
      props: {},
      sections: sectionData.handle as IFluidHandle<SharedObjectSequence<SectionData>>
    });
    const stackData = this.root.get<StackData>('stackData');
    this._sectionsData = await stackData.sections.get();
interface StackData {
  sections: IFluidHandle<SharedObjectSequence<SectionData>>;
  props: StackProps;
}
interface StackProps {}

A later insert (on user action) seems to trigger the assert.

Expected behavior

No assertion.

Logs

sureshsitaula-personal avatar Sep 22 '20 17:09 sureshsitaula-personal