fix(container-runtime): Always close the container if ContainerRuntime.flush throws#24318
Merged
markfields merged 3 commits intomicrosoft:mainfrom Apr 11, 2025
Merged
fix(container-runtime): Always close the container if ContainerRuntime.flush throws#24318markfields merged 3 commits intomicrosoft:mainfrom
markfields merged 3 commits intomicrosoft:mainfrom
Conversation
| } catch (newError: unknown) { | ||
| if ((newError as Partial<Error>).message === "Invalid string length") { | ||
| } catch (error: unknown) { | ||
| if ((error as Partial<Error>).message === "Invalid string length") { |
There was a problem hiding this comment.
[nitpick] Comparing the error message string directly may be brittle across different environments or future updates. Consider checking for the error type or a more robust property to determine if the error is due to string length issues.
Suggested change
| if ((error as Partial<Error>).message === "Invalid string length") { | |
| if ((error as Partial<Error>).name === "RangeError") { |
Member
Author
There was a problem hiding this comment.
Interesting. Not going to change this now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Flush is often called from secondary callstacks such that an error thrown will not propagate up to user code. However, failure to flush is a fatal error that we cannot recover from.
This change adds a try-catch to
ContainerRuntime.flushto ensure that the container is always closed if an error is thrown. I also went through all the errors thrown underneath there and made some tweaks to make them easier to interpret. e.g. usingDataProcessingErrormore, since this is an error type we expect consumers to monitor closely (we wouldn't want an app to sweep these flush errors under the rug).