Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions packages/dds/task-manager/src/taskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function assertIsTaskManagerOperation(op: unknown): asserts op is ITaskManagerOp
typeof op.taskId === "string" &&
"type" in op &&
(op.type === "volunteer" || op.type === "abandon" || op.type === "complete"),
"Not a TaskManager operation",
0xc3b /* Not a TaskManager operation */,
);
}

Expand Down Expand Up @@ -146,11 +146,11 @@ export class TaskManagerClass
(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {
if (local) {
const latestPendingOps = this.latestPendingOps.get(taskId);
assert(latestPendingOps !== undefined, "No pending ops for task");
assert(latestPendingOps !== undefined, 0xc3c /* No pending ops for task */);
const pendingOp = latestPendingOps.shift();
assert(
pendingOp !== undefined && pendingOp.messageId === messageId,
"Unexpected op",
0xc3d /* Unexpected op */,
);
assert(pendingOp.type === "volunteer", 0x07c /* "Unexpected op type" */);
if (latestPendingOps.length === 0) {
Expand All @@ -167,11 +167,11 @@ export class TaskManagerClass
(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {
if (local) {
const latestPendingOps = this.latestPendingOps.get(taskId);
assert(latestPendingOps !== undefined, "No pending ops for task");
assert(latestPendingOps !== undefined, 0xc3e /* No pending ops for task */);
const pendingOp = latestPendingOps.shift();
assert(
pendingOp !== undefined && pendingOp.messageId === messageId,
"Unexpected op",
0xc3f /* Unexpected op */,
);
assert(pendingOp.type === "abandon", 0x07e /* "Unexpected op type" */);
if (latestPendingOps.length === 0) {
Expand All @@ -189,11 +189,11 @@ export class TaskManagerClass
(taskId: string, clientId: string, local: boolean, messageId: number | undefined) => {
if (local) {
const latestPendingOps = this.latestPendingOps.get(taskId);
assert(latestPendingOps !== undefined, "No pending ops for task");
assert(latestPendingOps !== undefined, 0xc40 /* No pending ops for task */);
const pendingOp = latestPendingOps.shift();
assert(
pendingOp !== undefined && pendingOp.messageId === messageId,
"Unexpected op",
0xc41 /* Unexpected op */,
);
assert(pendingOp.type === "complete", 0x401 /* Unexpected op type */);
if (latestPendingOps.length === 0) {
Expand Down Expand Up @@ -682,11 +682,11 @@ export class TaskManagerClass
protected reSubmitCore(content: unknown, localOpMetadata: number): void {
assertIsTaskManagerOperation(content);
const pendingOps = this.latestPendingOps.get(content.taskId);
assert(pendingOps !== undefined, "No pending ops for task on resubmit attempt");
assert(pendingOps !== undefined, 0xc42 /* No pending ops for task on resubmit attempt */);
const pendingOpIndex = pendingOps.findIndex(
(op) => op.messageId === localOpMetadata && op.type === content.type,
);
assert(pendingOpIndex !== -1, "Could not match pending op on resubmit attempt");
assert(pendingOpIndex !== -1, 0xc43 /* Could not match pending op on resubmit attempt */);
pendingOps.splice(pendingOpIndex, 1);
if (pendingOps.length === 0) {
this.latestPendingOps.delete(content.taskId);
Expand Down Expand Up @@ -841,7 +841,7 @@ export class TaskManagerClass
return false;
}

assert(this.clientId !== undefined, 0x07f /* "clientId undefined" */);
assert(this.clientId !== undefined, 0xc44 /* clientId undefined */);

const inQueue = this.taskQueues.get(taskId)?.includes(this.clientId) ?? false;
const latestPendingOps = this.latestPendingOps.get(taskId);
Expand Down Expand Up @@ -879,14 +879,17 @@ export class TaskManagerClass
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.rollback}
*/
protected rollback(content: unknown, localOpMetadata: unknown): void {
assert(typeof localOpMetadata === "number", "Expect localOpMetadata to be a number");
assert(
typeof localOpMetadata === "number",
0xc45 /* Expect localOpMetadata to be a number */,
);
assertIsTaskManagerOperation(content);
const latestPendingOps = this.latestPendingOps.get(content.taskId);
assert(latestPendingOps !== undefined, "No pending ops when trying to rollback");
assert(latestPendingOps !== undefined, 0xc46 /* No pending ops when trying to rollback */);
const pendingOpToRollback = latestPendingOps.pop();
assert(
pendingOpToRollback !== undefined && pendingOpToRollback.messageId === localOpMetadata,
"pending op mismatch",
0xc47 /* pending op mismatch */,
);
if (latestPendingOps.length === 0) {
this.latestPendingOps.delete(content.taskId);
Expand Down
14 changes: 7 additions & 7 deletions packages/dds/tree/src/simple-tree/api/dirtyIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): Annou

return createAnnouncedVisitor({
beforeDetach: (src) => {
assert(parent !== undefined, "Expected node");
assert(parentField !== undefined, "Expected field");
assert(parent !== undefined, 0xc48 /* Expected node */);
assert(parentField !== undefined, 0xc49 /* Expected field */);
for (let parentIndex = src.start; parentIndex < src.end; parentIndex++) {
const path: UpPath = {
parent,
Expand All @@ -95,8 +95,8 @@ function createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): Annou
}
},
afterAttach: (_, dst) => {
assert(parent !== undefined, "Expected node");
assert(parentField !== undefined, "Expected field");
assert(parent !== undefined, 0xc4a /* Expected node */);
assert(parentField !== undefined, 0xc4b /* Expected field */);
for (let parentIndex = dst.start; parentIndex < dst.end; parentIndex++) {
const path: UpPath = {
parent,
Expand All @@ -116,7 +116,7 @@ function createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): Annou
}
},
enterNode(index: number): void {
assert(parentField !== undefined, "Expected field");
assert(parentField !== undefined, 0xc4c /* Expected field */);
parent = {
parent,
parentField,
Expand All @@ -125,7 +125,7 @@ function createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): Annou
parentField = undefined;
},
exitNode(): void {
assert(parent !== undefined, "Expected node");
assert(parent !== undefined, 0xc4d /* Expected node */);
parentField = parent.parentField;
parent = parent.parent;
},
Expand All @@ -141,7 +141,7 @@ function createDirtyVisitor(forest: IEditableForest, dirty: DirtyTreeMap): Annou
function getNodeAtPath(forest: IEditableForest, path: UpPath): TreeNode | undefined {
const cursor = forest.allocateCursor();
forest.moveCursorToPath(path, cursor);
assert(cursor.mode === CursorLocationType.Nodes, 0xa9c /* attach should happen in a node */);
assert(cursor.mode === CursorLocationType.Nodes, 0xc4e /* attach should happen in a node */);
const anchor = cursor.buildAnchor();
const anchorNode = forest.anchors.locate(anchor);
cursor.free();
Expand Down
8 changes: 4 additions & 4 deletions packages/dds/tree/src/simple-tree/core/treeNodeKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class KernelEventBuffer implements Listenable<KernelEvents> {
if (!this.#events.hasListeners(eventName)) {
assert(
!this.#disposeSourceListeners.has(eventName),
"Should not have a dispose function without listeners",
0xc4f /* Should not have a dispose function without listeners */,
);

const off = this.#eventSource.on(eventName, (args) => this.#emit(eventName, args));
Expand Down Expand Up @@ -479,7 +479,7 @@ class KernelEventBuffer implements Listenable<KernelEvents> {
this.#assertNotDisposed();
switch (eventName) {
case "childrenChangedAfterBatch":
assert(arg !== undefined, "childrenChangedAfterBatch should have arg");
assert(arg !== undefined, 0xc50 /* childrenChangedAfterBatch should have arg */);
return this.#handleChildrenChangedAfterBatch(arg.changedFields);
case "subtreeChangedAfterBatch":
return this.#handleSubtreeChangedAfterBatch();
Expand Down Expand Up @@ -526,7 +526,7 @@ class KernelEventBuffer implements Listenable<KernelEvents> {
}

#assertNotDisposed(): void {
assert(!this.#disposed, "Event handler disposed.");
assert(!this.#disposed, 0xc51 /* Event handler disposed. */);
}

public dispose(): void {
Expand All @@ -536,7 +536,7 @@ class KernelEventBuffer implements Listenable<KernelEvents> {

assert(
this.#childrenChangedBuffer.size === 0 && !this.#subTreeChangedBuffer,
"Buffered kernel events should have been flushed before disposing.",
0xc52 /* Buffered kernel events should have been flushed before disposing. */,
);

this.#disposeOnFlushListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ export class BlobManager {
const redirectTableEntries = [...this.redirectTable.entries()];
for (const [localId, detachedStorageId] of redirectTableEntries) {
const newStorageId = detachedStorageTable.get(detachedStorageId);
assert(newStorageId !== undefined, "Couldn't find a matching storage ID");
assert(newStorageId !== undefined, 0xc53 /* Couldn't find a matching storage ID */);
this.setRedirection(localId, newStorageId);
// set identity (id -> id) entry
this.setRedirection(newStorageId, newStorageId);
Expand Down
38 changes: 26 additions & 12 deletions packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ export const shortCodeMap = {
"0x078": "Possible re-entrancy! Summary should not already be in progress.",
"0x079": "Possible re-entrancy! Summary should have been in progress.",
"0x07a": "Services should be there to attach delta handler",
"0x07b": "Unexpected op",
"0x07c": "Unexpected op type",
"0x07d": "Unexpected op",
"0x07e": "Unexpected op type",
"0x07f": "clientId undefined",
"0x080": "Invalid document service!",
Expand Down Expand Up @@ -376,7 +374,6 @@ export const shortCodeMap = {
"0x250": "serialized container with attachment blobs must be rehydrated with detached blob storage",
"0x251": "creation summary has to have seq=0 && handle === undefined",
"0x252": "redirect table can only be set in detached container",
"0x254": "unrecognized id in redirect table",
"0x258": "connected",
"0x25b": "Caller is responsible for checking lock",
"0x25d": "We should never connect as 'read'",
Expand Down Expand Up @@ -510,13 +507,10 @@ export const shortCodeMap = {
"0x37f": "reentrancy?",
"0x380": "reentrancy?",
"0x381": "processDeltas() should run async",
"0x382": "'redirectTable' must contain only undefined while detached / defined values while attached",
"0x383": "requesting unknown blobs",
"0x384": "requesting handle for unknown blob",
"0x385": "For clarity and paranoid defense against adding future attachment states",
"0x386": "Must have pending blob entry for uploaded blob",
"0x38f": "local online BlobAttach op with no pending blob entry",
"0x390": "Must be attached to get GC data",
"0x391": "Redirect table size must match BlobManager's local ID count",
"0x395": "it's one and the same thing",
"0x397": "Unexpected summary stage",
Expand Down Expand Up @@ -573,10 +567,7 @@ export const shortCodeMap = {
"0x3fa": "Invalid interleaving of before/after slide",
"0x3fe": "id must exist on the interval",
"0x3ff": "pos2 should not be undefined here",
"0x400": "Unexpected op",
"0x401": "Unexpected op type",
"0x402": "pendingIds is empty",
"0x403": "Removed complete op id does not match",
"0x404": "Optional fields only support a single child node",
"0x406": "can only nextNode when in Nodes",
"0x408": "PathNode must be alive",
Expand Down Expand Up @@ -776,8 +767,6 @@ export const shortCodeMap = {
"0x5ad": "Cannot change the markerId of an existing marker",
"0x5b0": "parent must exist",
"0x5b9": "Cannot exit inexistent transaction",
"0x5bb": "Must be attached to run GC",
"0x5bc": "Must be attached to run GC",
"0x5bd": "Invalid blob node path",
"0x5c0": "AttributionCollection channel update should have consistent segment length",
"0x5c1": "local attribution keys should never be put in summaries",
Expand Down Expand Up @@ -1869,5 +1858,30 @@ export const shortCodeMap = {
"0xc37": "Unexpected pending data for createSubDirectory op",
"0xc38": "Unexpected pending data for deleteSubDirectory op",
"0xc39": "Subdirectory should exist",
"0xc3a": "seqData should be defined"
"0xc3a": "seqData should be defined",
"0xc3b": "Not a TaskManager operation",
"0xc3c": "No pending ops for task",
"0xc3d": "Unexpected op",
"0xc3e": "No pending ops for task",
"0xc3f": "Unexpected op",
"0xc40": "No pending ops for task",
"0xc41": "Unexpected op",
"0xc42": "No pending ops for task on resubmit attempt",
"0xc43": "Could not match pending op on resubmit attempt",
"0xc44": "clientId undefined",
"0xc45": "Expect localOpMetadata to be a number",
"0xc46": "No pending ops when trying to rollback",
"0xc47": "pending op mismatch",
"0xc48": "Expected node",
"0xc49": "Expected field",
"0xc4a": "Expected node",
"0xc4b": "Expected field",
"0xc4c": "Expected field",
"0xc4d": "Expected node",
"0xc4e": "attach should happen in a node",
"0xc4f": "Should not have a dispose function without listeners",
"0xc50": "childrenChangedAfterBatch should have arg",
"0xc51": "Event handler disposed.",
"0xc52": "Buffered kernel events should have been flushed before disposing.",
"0xc53": "Couldn't find a matching storage ID"
};
Loading