Skip to content

Fix blob attachment when using batches (Fixes #4166)#4192

Merged
DLehenbauer merged 3 commits into
mainfrom
flushmode
Oct 30, 2020
Merged

Fix blob attachment when using batches (Fixes #4166)#4192
DLehenbauer merged 3 commits into
mainfrom
flushmode

Conversation

@DLehenbauer
Copy link
Copy Markdown
Contributor

When batching, the container runtime was clobbering the { blobId: * } metadata with { batch: true/false }.

// If the batch contains only a single op, clear the batch flag.
if (messages.length === 1) {
delete messages[0].metadata;
delete firstMessageMetadata.batch;
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.

First bug: should delete the 'batch: true' flag, not the entire message metadata.

// Set the batch flag to false on the last message to indicate the end of the send batch
const lastMessage = messages[messages.length - 1];
lastMessage.metadata = { ...lastMessage.metadata, ...{ batch: false } };
lastMessage.metadata = { ...lastMessage.metadata, batch: false };
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.

(Opportunistic cleanup... not a bug.)

batchBegin = true;
// eslint-disable-next-line no-param-reassign
opMetadata = { ...opMetadata, batch: true };
this.needsFlush = true;
Copy link
Copy Markdown
Contributor Author

@DLehenbauer DLehenbauer Oct 30, 2020

Choose a reason for hiding this comment

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

Second bug was replacing metadata with { batch: true } (below).

'batchBegin' flag was only used to determine whether to set { batch: true }.

@DLehenbauer DLehenbauer changed the title Fix blob attachment when using batches (#4166) Fix blob attachment when using batches (Fixes #4166) Oct 30, 2020
@msfluid-bot
Copy link
Copy Markdown
Collaborator

msfluid-bot commented Oct 30, 2020

@fluidframework/base-host: No change
Metric NameBaseline SizeCompare SizeSize Diff
main.js 163.58 KB 163.58 KB No change
Total Size 163.58 KB 163.58 KB No change
@fluid-example/bundle-size-tests: +15 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
container.js 180.66 KB 180.68 KB +15 Bytes
map.js 39.79 KB 39.79 KB No change
matrix.js 137.45 KB 137.45 KB No change
odspDriver.js 191.48 KB 191.48 KB No change
sharedString.js 167.6 KB 167.6 KB No change
Total Size 716.98 KB 717 KB +15 Bytes

Baseline commit: 87845fd

Generated by 🚫 dangerJS against 7b04b15

content: any,
localOpMetadata: unknown,
opMetaData: unknown,
opMetadata: Record<string, unknown> | undefined,
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.

'opMetadata' must be constrained to "map-like objects" to ensure we can merge.

(Also, opMetaData -> opMetadata)

Comment thread packages/runtime/container-runtime/src/containerRuntime.ts
@DLehenbauer
Copy link
Copy Markdown
Contributor Author

Thanks, @wes-carlson !

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.

3 participants