Skip to content

Commit 2c846ae

Browse files
authored
Relax assert for getPendingBlobs() (#25671)
1 parent 74564c1 commit 2c846ae

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/runtime/container-runtime/src/blobManager/blobManager.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -941,16 +941,16 @@ export class BlobManager {
941941
const localBlobRecord = this.localBlobCache.get(localId);
942942
assert(localBlobRecord !== undefined, 0xc83 /* Pending blob must be in local cache */);
943943
assert(
944-
localBlobRecord.state === "uploading" ||
945-
localBlobRecord.state === "uploaded" ||
946-
localBlobRecord.state === "attaching",
947-
0xc84 /* Pending blob must be in uploading, uploaded, or attaching state */,
944+
localBlobRecord.state !== "attached",
945+
0xc84 /* Pending blob must not be in attached state */,
948946
);
949-
// We treat blobs in both uploaded and attaching state as just being uploaded, to distrust
950-
// whether we expect to see any ack for a BlobAttach op. We just remain prepared to handle
951-
// a BlobAttach op for it if we do see one after loading from pending state.
947+
// We downgrade uploading blobs to localOnly, and attaching blobs to uploaded. In the case of
948+
// uploading blobs, we don't have a way to retrieve the eventual storageId so the upload will
949+
// need to be restarted anyway. In the case of attaching blobs, we can't know whether the
950+
// BlobAttach op will eventually be ack'd. So we assume we'll need to send another op, but also
951+
// remain prepared to handle seeing the ack of the original op after loading from pending state.
952952
pendingBlobs[localId] =
953-
localBlobRecord.state === "uploading"
953+
localBlobRecord.state === "localOnly" || localBlobRecord.state === "uploading"
954954
? {
955955
state: "localOnly",
956956
blob: bufferToString(localBlobRecord.blob, "base64"),

packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,5 +1896,5 @@ export const shortCodeMap = {
18961896
"0xc81": "Attempting to upload from unexpected state",
18971897
"0xc82": "Attempting to attach from unexpected state",
18981898
"0xc83": "Pending blob must be in local cache",
1899-
"0xc84": "Pending blob must be in uploading, uploaded, or attaching state"
1899+
"0xc84": "Pending blob must not be in attached state"
19001900
};

0 commit comments

Comments
 (0)