Skip to content

Remove FlushModeExperimental.Async and all associated infrastructure#26579

Merged
anthony-murphy merged 6 commits intomainfrom
copilot/remove-flushmodeexperimental-async
Mar 2, 2026
Merged

Remove FlushModeExperimental.Async and all associated infrastructure#26579
anthony-murphy merged 6 commits intomainfrom
copilot/remove-flushmodeexperimental-async

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

FlushModeExperimental.Async was dead code — never promoted to a real API (cast via as unknown as FlushMode), incompatible with offline mode, and unused in practice. This removes it entirely.

Description

  • runtime-definitions: Deleted FlushModeExperimental enum; removed from index exports.
  • containerRuntime.ts:
    • Removed FlushModeExperimental import.
    • Removed FlushModeFallback constructor logic (the referenceSequenceNumbers loader feature check and conditional fallback to TurnBased). _flushMode is now set directly from runtimeOptions.flushMode.
    • Removed supportedFeatures from context destructuring (no longer read).
    • Removed case FlushModeExperimental.Async as unknown as FlushMode branch from scheduleFlush().
    • Added explicit validation that throws a UsageError (and calls closeFn) if flushMode is not FlushMode.Immediate or FlushMode.TurnBased, ensuring hosts passing invalid/stale values get a clear error instead of hitting an internal assertion. The validation is annotated with // TODO: Added in 2.90.0 - Remove this validation once we've released and confirmed no consumer passes an invalid flushMode value. to make it easy to identify when it is safe to remove.
  • containerRuntime.spec.ts:
    • Removed the "Container feature detection" describe block (tested fallback behavior), removed FlushModeExperimental.Async from orderSequentially flush mode arrays, removed it from container load stats runtimeOptions, and cleaned up unused imports (ILayerCompatDetails, IProvideLayerCompatDetails).
    • Fixed biome formatting on orderSequentially flush mode arrays (collapsed to single-line after removal of the third element).
    • Added unit test "Throws UsageError and calls closeFn for invalid flushMode" in the Batching describe block, asserting that passing a stale numeric value (e.g., the former FlushModeExperimental.Async = 2) rejects with a UsageError and invokes closeFn with the same error.
  • fewerBatches.spec.ts: Removed the FlushModeExperimental.Async batch count test case and import.

Breaking Changes

FlushModeExperimental is removed from @fluidframework/runtime-definitions. Any code importing or referencing FlushModeExperimental.Async will break. Since this was @internal and @experimental, no public API consumers should be affected.

Reviewer Guidance

The FlushMode.Immediate legacy path (1.x compat) is intentionally left untouched per the issue scope — that's a separate cleanup.

The flushMode validation block in the constructor is intentionally temporary — it guards against hosts that may still pass the old Async numeric value (2) from plain JS. It is tagged with the version it was introduced in (2.90.0) so it can be safely removed once we've released and confirmed no consumer hits it.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove FlushModeExperimental.Async and all associated infrastructure</issue_title>
<issue_description>## Summary

FlushModeExperimental.Async is effectively dead code. It should be removed along with all supporting infrastructure across layers and tests.

Why

  • It's cast through unknown to fit the FlushMode type (as unknown as FlushMode), indicating it was never promoted to a real API
  • It falls back to FlushMode.TurnBased if the loader doesn't support reference sequence numbers
  • It's incompatible with offline mode (batchIdTrackingEnabled)
  • The only flush mode anyone actually uses is FlushMode.TurnBased (default for minVersionForCollab >= "2.0.0-defaults")
  • FlushMode.Immediate is also only used for ancient 1.x compat (minVersionForCollab: "1.0.0") but is a separate cleanup

Scope

  • Remove FlushModeExperimental.Async enum value and its type definition
  • Remove the case FlushModeExperimental.Async as unknown as FlushMode branch in scheduleFlush()
  • Remove the FlushModeFallback logic in the constructor that checks loader support for reference sequence numbers
  • Remove any tests that exercise the Async flush mode
  • Clean up any imports of FlushModeExperimental that become unused
  • Search across all packages (not just container-runtime) for references

Notes

  • FlushMode.Immediate is a separate piece of legacy code (1.x compat) and could be addressed in a follow-up
  • The referenceSequenceNumbers feature gate check in the constructor may also become removable if only needed for the Async fallback path</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: anthony-murphy <1951092+anthony-murphy@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove FlushModeExperimental.Async and associated infrastructure Remove FlushModeExperimental.Async and all associated infrastructure Feb 27, 2026
@anthony-murphy
Copy link
Copy Markdown
Contributor

/azp run Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - client packages, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build site

@anthony-murphy
Copy link
Copy Markdown
Contributor

/azp run Build - test-tools, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the unused FlushModeExperimental.Async flush mode and the associated runtime/test infrastructure, simplifying flush-mode handling and eliminating dead/never-promoted API surface in the runtime layer.

Changes:

  • Removed FlushModeExperimental from @fluidframework/runtime-definitions and stopped exporting it from the package index.
  • Simplified ContainerRuntime flush-mode logic by removing Async handling and the loader feature-detection fallback path.
  • Deleted/updated tests that exercised Async flush mode and cleaned up now-unused imports.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/test/test-end-to-end-tests/src/test/fewerBatches.spec.ts Removes the Async flush-mode test case and simplifies test naming to rely only on FlushMode.
packages/runtime/runtime-definitions/src/index.ts Stops exporting FlushModeExperimental from the runtime-definitions barrel.
packages/runtime/runtime-definitions/src/dataStoreContext.ts Deletes the FlushModeExperimental enum definition.
packages/runtime/container-runtime/src/test/containerRuntime.spec.ts Removes Async-related test coverage and associated feature-detection/fallback tests and imports.
packages/runtime/container-runtime/src/containerRuntime.ts Removes Async-specific constructor fallback logic and the Async branch in scheduleFlush().

Comment thread packages/runtime/container-runtime/src/containerRuntime.ts
Co-authored-by: anthony-murphy <1951092+anthony-murphy@users.noreply.github.com>
Co-authored-by: anthony-murphy <1951092+anthony-murphy@users.noreply.github.com>
…p tracking

Co-authored-by: anthony-murphy <1951092+anthony-murphy@users.noreply.github.com>
@anthony-murphy
Copy link
Copy Markdown
Contributor

/azp run Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - client packages, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build site

@anthony-murphy
Copy link
Copy Markdown
Contributor

/azp run Build - test-tools, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@anthony-murphy anthony-murphy marked this pull request as ready for review February 27, 2026 01:18
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +1834 to +1841
this._flushMode = runtimeOptions.flushMode;
// TODO: Added in 2.90.0 - Remove this validation once we've released and confirmed no consumer passes an invalid flushMode value.
if (this._flushMode !== FlushMode.Immediate && this._flushMode !== FlushMode.TurnBased) {
const error = new UsageError(
"Invalid flushMode runtime option. Expected FlushMode.Immediate or FlushMode.TurnBased.",
);
this.closeFn(error);
throw error;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new constructor validation for runtimeOptions.flushMode is important behavior (rejecting stale/invalid numeric values like the former Async = 2). There isn’t a unit test asserting that ContainerRuntime.loadRuntime2() throws a UsageError (and closes) when an invalid flushMode is provided. Adding a test would prevent regressions and confirm the temporary guard works as intended.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a unit test "Throws UsageError and calls closeFn for invalid flushMode" in the Batching describe block in afba4e0. The test passes 2 (the former FlushModeExperimental.Async value) as an invalid flushMode and verifies that loadRuntime2 rejects with a UsageError and that closeFn is called with the same error.

@anthony-murphy
Copy link
Copy Markdown
Contributor

@copilot the build is failing. you need ensure it passes. looks like the build is generating edits, which is allowed, and those need to be part of the PR

Co-authored-by: anthony-murphy <1951092+anthony-murphy@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot the build is failing. you need ensure it passes. looks like the build is generating edits, which is allowed, and those need to be part of the PR

Fixed in afba4e0. The biome formatter wanted to collapse two-item arrays to a single line after FlushModeExperimental.Async was removed from them. The for loop arrays and template literal expressions in containerRuntime.spec.ts have been reformatted, which should resolve the check:format:repo failure.

@anthony-murphy
Copy link
Copy Markdown
Contributor

/azp run Build - api-markdown-documenter, Build - benchmark-tool, Build - build-common, Build - build-tools, Build - client packages, Build - common-utils, Build - eslint-config-fluid, Build - eslint-plugin-fluid, Build - protocol-definitions, Build site

@anthony-murphy
Copy link
Copy Markdown
Contributor

/azp run Build - test-tools, repo-policy-check, server-gitrest, server-gitssh, server-historian, server-routerlicious

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@anthony-murphy anthony-murphy merged commit 70a57c7 into main Mar 2, 2026
39 checks passed
@anthony-murphy anthony-murphy deleted the copilot/remove-flushmodeexperimental-async branch March 2, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove FlushModeExperimental.Async and all associated infrastructure

4 participants