Skip to content

Commit b3057c2

Browse files
agarwal-navinanthony-murphy-agent
authored andcommitted
(compat) Added a new error type for layer incompatibility error (microsoft#25784)
Follow up to microsoft#25706. Added a new error type `layerIncompatibilityError` which will be used when a layer incompatibility is detected between Fluid layers. This will help applications detect when an error is because of layer incompatibility and take appropriate steps. The new error type is added as an legacy / alpha API. Since the `FluidErrorTypes` type is legacy / beta, added a `FluidErrorTypesAlpha` type where new error types will be added to stage them. Once the breaking change window has passed, error types will be moved to `FluidErrorTypes`. [AB#51811](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/51811)
1 parent 67b21a8 commit b3057c2

File tree

12 files changed

+553
-32
lines changed

12 files changed

+553
-32
lines changed

.changeset/sweet-groups-love.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@fluidframework/core-interfaces": minor
3+
"@fluidframework/container-definitions": minor
4+
"__section": legacy
5+
---
6+
Added a new Fluid error type layerIncompatibilityError
7+
8+
A new Fluid error type `layerIncompatibilityError` is added to `FluidErrorTypesAlpha` as @legacy @alpha. This will be moved to `FluidErrorTypes` as @legacy @beta in a future legacy breaking release.
9+
It will also be added to `ContainerErrorTypes` since it extends `FluidErrorTypes`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4+
"mainEntryPointFilePath": "<projectFolder>/dist/legacy.alpha.d.ts"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4+
"mainEntryPointFilePath": "<projectFolder>/lib/legacy.alpha.d.ts"
5+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3-
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.legacy.json"
3+
"extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.legacy.json",
4+
"mainEntryPointFilePath": "<projectFolder>/lib/legacy.alpha.d.ts",
5+
"apiReport": {
6+
"reportVariants": ["public", "beta", "alpha"]
7+
}
48
}

packages/common/core-interfaces/api-report/core-interfaces.legacy.alpha.api.md

Lines changed: 473 additions & 0 deletions
Large diffs are not rendered by default.

packages/common/core-interfaces/package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
"default": "./dist/index.js"
3434
}
3535
},
36+
"./legacy/alpha": {
37+
"import": {
38+
"types": "./lib/legacy.alpha.d.ts",
39+
"default": "./lib/index.js"
40+
},
41+
"require": {
42+
"types": "./dist/legacy.alpha.d.ts",
43+
"default": "./dist/index.js"
44+
}
45+
},
3646
"./internal": {
3747
"import": {
3848
"types": "./lib/internal.d.ts",
@@ -52,8 +62,8 @@
5262
"types": "lib/public.d.ts",
5363
"scripts": {
5464
"api": "fluid-build . --task api",
55-
"api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
56-
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
65+
"api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./dist",
66+
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./lib --node10TypeCompat",
5767
"build": "fluid-build . --task build",
5868
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
5969
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
@@ -71,8 +81,10 @@
7181
"check:exports": "concurrently \"npm:check:exports:*\"",
7282
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
7383
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
84+
"check:exports:cjs:legacy.alpha": "api-extractor run --config api-extractor/api-extractor-lint-legacy.alpha.cjs.json",
7485
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
7586
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
87+
"check:exports:esm:legacy.alpha": "api-extractor run --config api-extractor/api-extractor-lint-legacy.alpha.esm.json",
7688
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
7789
"check:format": "npm run check:biome",
7890
"ci:build": "npm run build:compile",

packages/common/core-interfaces/src/cjs/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"types": "./legacy.d.ts",
1111
"default": "./index.js"
1212
},
13+
"./legacy/alpha": {
14+
"types": "./legacy.alpha.d.ts",
15+
"default": "./index.js"
16+
},
1317
"./internal": {
1418
"types": "./internal.d.ts",
1519
"default": "./internal.js"

packages/common/core-interfaces/src/error.ts

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ export const FluidErrorTypes = {
4141
*/
4242
export type FluidErrorTypes = (typeof FluidErrorTypes)[keyof typeof FluidErrorTypes];
4343

44+
/**
45+
* New error types that are still in alpha stage. Once stabilized, they will be moved to FluidErrorTypes.
46+
* @legacy @alpha
47+
*/
48+
export const FluidErrorTypesAlpha = {
49+
...FluidErrorTypes,
50+
/**
51+
* Error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is
52+
* not compatible with the Runtime layer, the container create / load will fail with an error of this type.
53+
* In most cases, the layer compatibility validation happens during container load / create causing it to
54+
* fail with this error type.
55+
* In some cases such as for the Runtime and DataStore layer compatibility, the incompatibility may be detected
56+
* during data store loads. In such cases, the data store load will fail with this error type.
57+
*/
58+
layerIncompatibilityError: "layerIncompatibilityError",
59+
} as const;
60+
61+
/**
62+
* @legacy @alpha
63+
*/
64+
export type FluidErrorTypesAlpha =
65+
(typeof FluidErrorTypesAlpha)[keyof typeof FluidErrorTypesAlpha];
66+
4467
/**
4568
* Base interface for all errors and warnings emitted the container.
4669
*
@@ -130,28 +153,15 @@ export interface IThrottlingWarning extends IErrorBase {
130153
}
131154

132155
/**
133-
* Symbol used to identify an error of type {@link ILayerIncompatibilityError}.
134-
* @legacy @alpha
135-
*/
136-
export const layerIncompatibilityErrorSymbol: unique symbol = Symbol(
137-
"LayerIncompatibilityError",
138-
);
139-
140-
/**
141-
* Usage error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is
156+
* Layer incompatibility error indicating that two Fluid layers are incompatible. For instance, if the Loader layer is
142157
* not compatible with the Runtime layer, the container will be disposed with this error.
143158
* @legacy @alpha
144159
*/
145160
export interface ILayerIncompatibilityError extends IErrorBase {
146161
/**
147162
* {@inheritDoc IErrorBase.errorType}
148163
*/
149-
readonly errorType: typeof FluidErrorTypes.usageError;
150-
151-
/**
152-
* Symbol used to identify this error as a layer incompatibility error.
153-
*/
154-
readonly [layerIncompatibilityErrorSymbol]: true;
164+
readonly errorType: typeof FluidErrorTypesAlpha.layerIncompatibilityError;
155165
/**
156166
* The layer that is reporting the incompatibility.
157167
*/

packages/common/core-interfaces/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ export type {
1414
IThrottlingWarning,
1515
ILayerIncompatibilityError,
1616
} from "./error.js";
17-
export { layerIncompatibilityErrorSymbol } from "./error.js";
18-
export { FluidErrorTypes } from "./error.js";
17+
export {
18+
FluidErrorTypes,
19+
FluidErrorTypesAlpha,
20+
} from "./error.js";
1921

2022
export type {
2123
ExtendEventProvider,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
runtimeCoreCompatDetails,
3131
} from "@fluidframework/container-runtime/internal";
3232
import {
33-
FluidErrorTypes,
33+
FluidErrorTypesAlpha,
3434
type ITelemetryBaseProperties,
3535
} from "@fluidframework/core-interfaces/internal";
3636
import {
@@ -225,7 +225,7 @@ function getExpectedErrorEvents(
225225
const expectedErrorEvents: ExpectedEvents = [
226226
{
227227
eventName: "fluid:telemetry:Container:ContainerDispose",
228-
errorType: FluidErrorTypes.usageError,
228+
errorType: FluidErrorTypesAlpha.layerIncompatibilityError,
229229
},
230230
];
231231

@@ -242,7 +242,7 @@ function getExpectedErrorEvents(
242242
// during data store realization, so we expect this error event to be logged.
243243
expectedErrorEvents.unshift({
244244
eventName: "fluid:telemetry:FluidDataStoreContext:RealizeError",
245-
errorType: FluidErrorTypes.usageError,
245+
errorType: FluidErrorTypesAlpha.layerIncompatibilityError,
246246
});
247247
} else if (layer2 === "dataStore" && flow === "create") {
248248
// In create flows, the layer compat validation in the Runtime layer happens during data store runtime
@@ -251,7 +251,7 @@ function getExpectedErrorEvents(
251251
// data store runtime attach flow, so we do not expect this error event to be logged.
252252
expectedErrorEvents.unshift({
253253
eventName: "fluid:telemetry:FluidDataStoreContext:AttachRuntimeError",
254-
errorType: FluidErrorTypes.usageError,
254+
errorType: FluidErrorTypesAlpha.layerIncompatibilityError,
255255
});
256256
}
257257

0 commit comments

Comments
 (0)