github microsoft/FluidFramework client_v3.14.0
Fluid Framework v3.14.0 (minor)

52 minutes ago

Contents

  • 🌳 SharedTree DDS Changes
    • Reduce the cost of reading nodes of a schema type for the first time (#28715)
    • Reduce the cost of trimming history that has no repair data (#28728)
    • Reduce view maintenance overhead for some SharedTree edits (#28742)
    • New compatibility APIs explain viewing and upgrade incompatibilities (#28789)
    • Preserve compact storage when replacing SharedTree leaf values (#28731)
    • Experimental preview of application-defined schema versions (#28176)
    • Optional fields can be removed from application schema without blocking later upgrades (#28778)
    • Schema compatibility snapshot errors explain viewing and upgrade failures (#28786)
    • Fix a memory leak where rewinding a view kept old history forever (#28780)
  • 🐛 Bug Fixes
    • Prevent data store ID collisions after restoring a detached container (#28725)
    • Failed snapshot prefetches and cache writes no longer cause unhandled promise rejections (#28751)
  • Legacy API Changes
    • Claims challenges from OneDrive and SharePoint can be returned to the host instead of being retried (#28751)

🌳 SharedTree DDS Changes

Reduce the cost of reading nodes of a schema type for the first time (#28715)

A node created by reading it from a tree no longer creates a default context for its schema, which only nodes created outside a tree use. The first use of a node schema whose containing schema was already validated no longer validates it again. This reduces the cost of reading nodes of many schema types for the first time, for example when loading a document.

Change details

Commit: ded708e

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Reduce the cost of trimming history that has no repair data (#28728)

When commits leave the collaboration window, their repair data (the content of removed nodes) is destroyed. Commits without repair data, such as inserts, no longer edit the forest when they are trimmed. This reduces the cost of receiving edits.

Change details

Commit: 8f79e45

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Reduce view maintenance overhead for some SharedTree edits (#28742)

When configured with ForestTypeOptimized, SharedTree reduces the cost of clearing cached navigation state during edits and the memory retained by that cleared state. Results depend on the document schema, workload, and environment; not all operations improve.

Example measurements

An application-level benchmark measures the first edit after initializing an array of 1,000 points with numeric x and y fields. It sets point.x = 1001 on the middle point. Initialization leaves cached navigation state for many nodes, which this first edit clears. The comparison isolates this change from the subsequent in-place leaf-editing optimization.

Metric Before After Change
First local edit time after initialization 0.780 ms 0.655 ms 16% less
Memory retained by the tree view after that edit 2.662 MiB 2.532 MiB 4.9% less

These results do not imply a comparable improvement for repeated edits to an already-edited document. The memory reduction comes from smaller retained navigation state, not a more compact representation of the document content.

Measurements use Node.js 22.23.2 and report means across two runs per implementation in an interleaved comparison. Timing covers the property assignment, excluding document initialization, point lookup, and result verification. Memory figures are per document after garbage collection, including content and editing history retained by the tree view; they do not measure peak memory.

Change details

Commit: 9707aad

Affected packages:

  • @fluidframework/tree

⬆️ Table of contents

New compatibility APIs explain viewing and upgrade incompatibilities (#28789)

When your view schema is incompatible with a document's stored schema, you need to know whether you can view the document, upgrade its schema, or do neither. The new beta APIs, asBeta(view).compatibility.view and .upgrade, explain these two operations separately. Each returns a CompatibilityResult: isCompatible: true means the operation is permitted, while isCompatible: false includes a nonempty incompatibilities list explaining what prevents it.

Start by checking compatibility.view.isCompatible before accessing the tree root. If viewing is blocked, its incompatibilities explain why, and you can check compatibility.upgrade.isCompatible to see whether a schema upgrade would allow you to proceed. If upgrading is also blocked, its own incompatibilities explain the schema requirements that prevent that option. Because these permissions are independent, a viewable document can still have a blocked upgrade, and a permitted upgrade is not necessarily needed.

To help you diagnose either failure, every SchemaViewIncompatibility and SchemaUpgradeIncompatibility includes a human-readable reason explaining the failed schema requirement and its location. Use these reasons for logging and debugging, or use mismatch and the structured fields when your application needs to handle a failure programmatically. The reasons describe schema requirements rather than application intent, so they do not prescribe a fix.

You can adopt the new results without replacing existing compatibility checks: canView and canUpgrade remain available for their respective operations. The existing discrepancies and SchemaDiscrepancy also remain available for viewing failures; SchemaViewIncompatibility adds reason to those same details. The new APIs use "incompatibility" to align with compatibility terminology, while existing API names are retained for compatibility. This change does not deprecate the existing APIs.

Here's an example of how the new APIs can be used:

import { asBeta } from "@fluidframework/tree/beta";

const { compatibility } = asBeta(view);
if (!compatibility.view.isCompatible) {
  for (const { reason } of compatibility.view.incompatibilities) {
    console.error(reason);
  }
  if (compatibility.upgrade.isCompatible) {
    view.upgradeSchema();
  } else {
    for (const { reason } of compatibility.upgrade.incompatibilities) {
      console.error(reason);
    }
  }
}

Change details

Commit: 2d212fe

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Preserve compact storage when replacing SharedTree leaf values (#28731)

When configured with ForestTypeOptimized, SharedTree preserves compact storage for compatible leaf-value replacements. This reduces editing overhead and retained memory in some workloads.

The optimization applies when editing locally, receiving edits from another client, or merging edits from a fork. Edits that cannot preserve the existing storage layout continue to use the general editing path. The effect depends on the document schema, workload, and environment.

Example measurements

Local benchmarks set bold from false to true across a fresh 1,000-character formatted-text document using formatRange(0, 1000, { bold: true }). Each character has five formatting properties: bold, italic, underline, size, and font. The comparison isolates these editing changes from earlier read-traversal improvements.

Metric Before After Change
Local edit time 191 ms 147 ms 23% less
Memory retained by the edited tree view 15.12 MiB 12.85 MiB 15% less
Receive queued edits from another client 70.4 ms 34.4 ms 51% less
Merge edits from a fork 61.4 ms 29.6 ms 52% less

Measurements use Node.js 22.23.2 and report means across two runs per implementation in an interleaved comparison. Local edit timing excludes document initialization and result verification. Memory figures are per document after garbage collection, including content and editing history retained by the tree view; they do not measure peak memory.

Remote-receive timing covers decoding and applying already-received edits in an in-memory test environment, excluding sender work and network delay. Fork-merge timing excludes creating and editing the fork. Neither incoming-edit case includes concurrent local edits on the receiver.

Change details

Commit: d375e23

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Experimental preview of application-defined schema versions (#28176)

As an application evolves, different parts of its schema may change at different times. Application-defined schema versions describe the schema with a single version number or multiple version numbers for different parts of the schema. SharedTree stores these versions with the schema and uses them to order upgrades, so older application versions cannot undo a versioned upgrade. The application controls version granularity, but the versions must not decrease across schema upgrades.

Experimental preview: The experimental stored-schema format is not suitable for production applications. Persisting these versions currently requires an experimental format. The configuration below explicitly overrides normal format selection and can therefore break collaboration with client versions the application supports. The experimental format will not necessarily be supported long-term, so documents written with it are not guaranteed to remain readable by future Fluid Framework versions. For preview testing, every client that loads or collaborates on the document must use the same Fluid Framework version. This constraint does not make the format suitable for production use.

Single application-wide version

An application that only needs one version can specify a non-negative safe integer in the schemaVersion option of identifySchema:

import {
  identifySchema,
  SchemaFactory,
  TreeViewConfigurationAlpha,
} from "fluid-framework/alpha";

const schemaFactory = new SchemaFactory("com.example");
class Note extends schemaFactory.object("Note", {
  id: schemaFactory.identifier,
  text: schemaFactory.string,
}) {}

const config = new TreeViewConfigurationAlpha({
  schema: Note,
  schemaIdentity: identifySchema({
    schemaVersion: 1,
  }),
});

The returned identity configures versioning through the schemaIdentity property of TreeViewConfigurationAlpha. Persisting the version during document initialization or upgrade also requires configuredSharedTreeAlpha to use the experimental stored-schema format. This configuration requires allowPossiblyIncompatibleWriteVersionOverrides to be true and writeVersionOverrides to include ["Schema", "schemaVersion"], as shown in the next example.

Independent versions for parts of the schema

When parts of a schema evolve independently, a version map can replace the single number. Each key identifies a part of the schema, and its value is a non-negative safe integer. Stable, globally unique string identifiers, such as package names or domain-based names, avoid conflicts with other libraries.

The following example defines notes and comments as application data and gives each node schema its own version. It uses each schema's identifier as the map key and a static version property to keep the corresponding version near its schema definition. These static properties are an application convention: SharedTree reads the map passed to schemaVersion, not the properties on the classes.

import {
  configuredSharedTreeAlpha,
  identifySchema,
  SchemaFactory,
  TreeViewConfigurationAlpha,
} from "fluid-framework/alpha";

const schemaFactory = new SchemaFactory("com.example");
class Note extends schemaFactory.object("Note", {
  id: schemaFactory.identifier,
  text: schemaFactory.string,
}) {
  static readonly version = 3;
}

class Comment extends schemaFactory.object("Comment", {
  id: schemaFactory.identifier,
  text: schemaFactory.string,
}) {
  static readonly version = 1;
}

class AppSchema extends schemaFactory.object("App", {
  notes: schemaFactory.array("Notes", Note),
  comments: schemaFactory.array("Comments", Comment),
}) {}

const SharedTree = configuredSharedTreeAlpha({
  allowPossiblyIncompatibleWriteVersionOverrides: true,
  writeVersionOverrides: new Map([["Schema", "schemaVersion"]]),
});

const config = new TreeViewConfigurationAlpha({
  schema: AppSchema,
  schemaIdentity: identifySchema({
    schemaVersion: {
      [Note.identifier]: Note.version,
      [Comment.identifier]: Comment.version,
    },
  }),
});

In this example, the next release changes the notes schema but leaves comments unchanged. That release increases Note.version from 3 to 4 while keeping Comment.version at 1. The map then records which feature's schema changed without assigning a new version to the unchanged parts of the application.

Consistent schema upgrades

An upgrade to an existing document must preserve its version identifiers and must not decrease their values. These rules prevent an older application from reversing an upgrade made by a newer one. Existing additive schema upgrades do not require a version increase. To make a change outside those rules, both the stored and new schemas must have version maps, and at least one version must increase or a new identifier must be added. Even then, the new schema must still accept all content allowed by the stored schema. Adding a version map for the first time does not bypass the additive upgrade rules.

upgradeSchema currently treats a version identifier missing from the view configuration as an attempt to remove that identifier from the stored schema. This includes configurations that declare no schema versions at all. Because upgrades cannot remove identifiers or decrease their values, an older application must declare every stored identifier with at least its stored version to make any schema upgrade, even an additive one. These version requirements apply to schema upgrades, not to reading or editing a document whose content is compatible with the view.

The single-number shorthand uses the identifier "schemaVersion" and follows the same upgrade rules as other identifiers. This identifier is not reserved: an application can use "schemaVersion" explicitly in a version record, and that entry refers to the same version as the single-number shorthand. Switching from schemaVersion: 3 to schemaVersion: { schemaVersion: 3 } therefore preserves the existing version rather than creating a new identifier. If the application later adds feature versions, this entry must remain alongside the new identifiers rather than being replaced. Its value can stay unchanged while only the feature versions increase.

Optional schema hashing

identifySchema provides versions without hashing. It does not compute hashes or log hash telemetry, avoiding the bundle-size cost of schema hashing. identifySchemaWithHash supports both hash telemetry and versions. Both factories remain alpha APIs imported from fluid-framework/alpha, but their names no longer include the Alpha suffix.

The hash-enabled factory also accepts expectedHash to check the configured schema during view construction. Versions are not included in the hash, so changing only the version map does not require a new expectedHash.

Separating the version-only and hash-enabled factories and removing the suffix is a breaking change for existing alpha API users of identifySchemaAlpha. Calls that enable hash checks or telemetry must switch to identifySchemaWithHash, keeping the same options. This includes calls with no options, which previously enabled hash telemetry.

// Before
const identity = identifySchemaAlpha({ expectedHash });

// After
const identity = identifySchemaWithHash({ expectedHash });

IdentifySchemaOptions types reusable options objects for the version-only factory, while IdentifySchemaWithHashOptions does the same for the hash-enabled factory.

Compatibility investigation

A schema compatibility investigation can start by comparing the versions the application expects with those stored in the document. On TreeViewAlpha, schemaVersion returns a TreeViewSchemaVersions object: schemaVersion.view contains the configured versions, and schemaVersion.stored contains the document's current versions. Each map uses the shared read-only SchemaVersions type, which documents version ordering and upgrade rules. A map is undefined when its schema has no application-defined versions. The stored versions are also available through ViewableTreeAlpha.storedSchemaVersion.

const configuredNotesVersion = view.schemaVersion.view?.get(Note.identifier);
const storedNotesVersion = view.schemaVersion.stored?.get(Note.identifier);

For example, the application might expect notes version 4 while the document stores version 3. If both still use comments version 1, the mismatch points to the notes schema as a useful starting point. The versions help explain the difference, but compatibility checks determine whether the document can be viewed or upgraded.

Version identifiers can also identify documents created by an experimental schema library, even after the experiment ends. Giving that library its own identifier distinguishes its documents from those that only use the rest of the application schema.

Versioned compatibility snapshots

For snapshot-based compatibility testing, exportCompatibilitySchemaSnapshot captures the configured versions alongside the schema. This lets compatibility checks between releases account for version changes as well as schema structure.

After the earlier example increases Note.version to 4, its snapshot contains the following version entries.

{
  "version": 2,
  "schemaVersion": [
    ["com.example.Comment", 1],
    ["com.example.Note", 4]
  ]
}

The top-level version identifies the snapshot format, not an application release or a node schema version. The application-defined versions appear in schemaVersion.

snapshotSchemaCompatibility also associates each snapshot file with a separate release version supplied through SnapshotSchemaCompatibilityOptions.version, typically the application or package version. Increasing Note.version changes the snapshot, but does not automatically increase that release version. In "assert" mode, the check reports an out-of-date snapshot if the existing snapshot still contains the previous node schema version. To also prevent "update" mode from overwriting a snapshot under the same release version, set rejectSchemaChangesWithNoVersionChange to true. The application must then advance the snapshot release version before saving the changed schema and its versions.

Change details

Commit: 7976bb9

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Optional fields can be removed from application schema without blocking later upgrades (#28778)

Object schema with allowUnknownOptionalFields enabled can now omit previously stored optional fields and still upgrade existing documents. SharedTree retains those fields and the node definitions they require, preserving their content for clients that still declare them. This supports rolling back schema changes or retiring features while continuing to evolve the schema.

For example, an application can remove notes and later add an unrelated optional field:

const factory = new SchemaFactory("tasks");

// Earlier application version.
class Before extends factory.object("Task", {
  title: factory.string,
  notes: factory.optional(factory.string),
}) {}

// Later application version: remove `notes` and add `isApproved`.
class After extends factory.object("Task", {
  title: factory.string,
  isApproved: factory.optional(factory.boolean),
}) {}

// Open a document initialized by the earlier version.
const view = tree.viewWith(new TreeViewConfiguration({ schema: After }));
if (view.compatibility.canUpgrade) {
  view.upgradeSchema();
}

In the above example, the stored schema upgrade adds isApproved while preserving the existing notes field.

Important

A field's stored identifier (its stored key) is permanent in existing documents. Removing the field from a view does not free that identifier for reuse with an incompatible definition.

For example, suppose a later version of Task declares notes: factory.optional(factory.array(factory.string)) using the same stored key as the original optional string field. That view cannot load or safely upgrade documents whose stored schema still permits the original string-valued notes field. This conflict exists even if the document contains no data under the old notes definition, because the stored schema still permits strings that another client could write later.

Use a different stored key for a different, incompatible field.

To detect such conflicts before releasing a schema change, keep historical schema snapshots and use snapshotSchemaCompatibility tests.

Schema Compatibility Snapshot Testing

Schema compatibility snapshot checks now accept either direct viewing or a safe upgrade in both directions, rather than only supporting upgrade in a forwards direction. For versions within minVersionForCollaboration, snapshotSchemaCompatibility requires canView || canUpgrade for each version viewing documents created with the other schema. The current version must also be able to view or upgrade documents from every historical snapshot outside that collaboration window. Clients that can already view a document remain supported even when they cannot upgrade it; clients that can do neither are rejected.

Important

Snapshot checks evaluate historical schemas using the currently installed Fluid Framework library versions, not the versions deployed with older clients. Before relying on older clients to upgrade while retaining unknown optional fields, deploy a version of the application that uses Fluid Framework library version 3.14.0 or higher.

Change details

Commit: b066596

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Schema compatibility snapshot errors explain viewing and upgrade failures (#28786)

Errors from snapshotSchemaCompatibility now include the diagnostic reasons for each failed comparison with a historical schema. For each failed comparison, separate sections explain why neither viewing nor upgrading is possible. The messages identify affected fields and node types, and preserve nested viewing reasons when a proposed schema upgrade would still prevent viewing. Compatibility requirements and snapshot update behavior are unchanged.

The following examples assume snapshots for versions 1.0.0 and 2.0.0 already exist and the latest snapshot matches the current schema. The snapshot directory is illustrative.

The current schema can neither view nor upgrade historical documents

Now suppose version 1.0.0 allows a number or a string at the root, but version 2.0.0 removes string support. Even with minVersionForCollaboration: "2.0.0", the current schema must still support historical documents. The proposed upgrade preserves their allowed string values, but the current view cannot handle them, so the error includes the nested viewing reason:

Schema compatibility check failed:
 - Current version "2.0.0" can neither view nor upgrade documents from "1.0.0".
   - Viewing failed:
     - Cannot view the root field: the stored schema allows node types ["com.fluidframework.leaf.string"] that the view does not allow.
   - Upgrade failed:
     - Cannot upgrade: the resulting stored schema would still prevent the view from reading or writing the document.
       - Cannot view the root field: the stored schema allows node types ["com.fluidframework.leaf.string"] that the view does not allow.
Snapshots in: "/app/schema-snapshots"
Snapshots exist for versions: [
	"1.0.0",
	"2.0.0"
].

Historical clients can neither view nor upgrade current documents

Suppose version 1.0.0 allows only a number at the root, while version 2.0.0 allows a number or a string. With minVersionForCollaboration: "1.0.0", the check fails because historical clients cannot handle the newly allowed strings:

Schema compatibility check failed:
 - Historical version "1.0.0" can neither view nor upgrade documents from "2.0.0": these versions are expected to be able to collaborate due to the selected `minVersionForCollaboration` "1.0.0".
   - Viewing failed:
     - Cannot view the root field: the stored schema allows node types ["com.fluidframework.leaf.string"] that the view does not allow.
   - Upgrade failed:
     - Cannot upgrade: the resulting stored schema would still prevent the view from reading or writing the document.
       - Cannot view the root field: the stored schema allows node types ["com.fluidframework.leaf.string"] that the view does not allow.
Snapshots in: "/app/schema-snapshots"
Snapshots exist for versions: [
	"1.0.0",
	"2.0.0"
].

Change details

Commit: d6ab2da

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

Fix a memory leak where rewinding a view kept old history forever (#28780)

rewindTo now disposes the branch it replaces, as its documentation says. Before this fix, the replaced branch stayed alive and kept SharedTree from trimming old history. That history stayed in memory for as long as the tree was loaded, even after the view was disposed.

Change details

Commit: e30b274

Affected packages:

  • @fluidframework/tree
  • fluid-framework

⬆️ Table of contents

🐛 Bug Fixes

Prevent data store ID collisions after restoring a detached container (#28725)

Creating data stores after you serialize and rehydrate a detached container no longer fails when unbound data stores were omitted from the snapshot. New detached data store IDs avoid existing data stores and aliases, preserving their contents when you attach and reload the container.

Change details

Commit: cd9cb0c

Affected packages:

  • @fluidframework/container-runtime

⬆️ Table of contents

Failed snapshot prefetches and cache writes no longer cause unhandled promise rejections (#28751)

prefetchLatestSnapshot returns false when it can't fetch the snapshot. Before this fix, the failure could also cause an unhandled promise rejection, for example when the odspDocumentServiceFactory argument wasn't given.

The driver writes each snapshot that it downloads to the host's persisted cache. Before this fix, if that write failed, the failure also caused an unhandled promise rejection. This could happen when loading a container or when prefetching a snapshot.

Change details

Commit: 7ebb881

Affected packages:

  • @fluidframework/odsp-driver

⬆️ Table of contents

Legacy API Changes

Claims challenges from OneDrive and SharePoint can be returned to the host instead of being retried (#28751)

A claims challenge is a 401 or 403 response with a WWW-Authenticate header that asks for a token with more claims. For more information, see Claims challenges. By default, the driver gets a new token one time and retries the request. It gives the decoded claims to the host's token fetcher in TokenFetchOptions.claims.

Some hosts can't satisfy the challenge themselves. For example, a service that makes requests for another client must send the challenge to that client. These hosts can now set the new propagateClaimsChallenges property of HostStoragePolicy to true. The driver then doesn't retry the request, and the operation fails with the original authorization error. The error has the decoded claims, and the raw header value in the new wwwAuthenticate property of IAuthorizationError.

import { DriverErrorTypes } from "@fluidframework/driver-definitions/legacy";
import { OdspDocumentServiceFactory } from "@fluidframework/odsp-driver/legacy";

const documentServiceFactory = new OdspDocumentServiceFactory(
  getStorageToken,
  getWebsocketToken,
  persistedCache,
  { propagateClaimsChallenges: true },
);

// ...

if (error.errorType === DriverErrorTypes.authorizationError && error.claims) {
  // Send error.wwwAuthenticate to the client, which can then get a token with the required claims.
}

To identify a claims challenge, check for a non-empty claims value, as in the example. Don't check for wwwAuthenticate, because the driver sets it on every authorization error from a response that has the header, even when propagateClaimsChallenges isn't true.

When propagateClaimsChallenges is true, the driver doesn't give the claims to the token fetcher. So when you load the document again after the challenge is satisfied, make sure that the token fetcher returns the new token, even when TokenFetchOptions.refresh is false.

As for other authorization errors, the driver clears its cached snapshot of the document when a snapshot request fails with the challenge. But a load can still succeed, because the driver can use a cached snapshot without waiting for the service. A later request, such as connecting to the delta stream or fetching ops, then gets the challenge, and the container closes with the error.

While the container is connected, the driver also refreshes its join session with the service in the background. If a refresh gets the challenge, the driver ends the delta stream connection with the error, and the container reconnects. The container then closes with the error, unless the token fetcher returns a token that satisfies the challenge. If the container doesn't reconnect, for example because it was loaded with the LoaderHeader.reconnect request header set to false, it closes without an error. The host then gets the challenge when it loads the container again.

So check for a claims challenge in the error of the container's closed event as well as in load errors.

propagateClaimsChallenges also applies to prefetchLatestSnapshot when the factory is passed in its odspDocumentServiceFactory parameter. It doesn't apply to OdspDriverUrlResolverForShareLink.

Change details

Commit: 7ebb881

Affected packages:

  • @fluidframework/driver-definitions
  • @fluidframework/odsp-driver
  • @fluidframework/odsp-driver-definitions

⬆️ Table of contents

🛠️ Start Building Today!

Please continue to engage with us on GitHub Discussion and Issue pages as you adopt Fluid Framework!

Don't miss a new FluidFramework release

NewReleases is sending notifications on new releases.