-
-
Notifications
You must be signed in to change notification settings - Fork 448
Add try-catch when reading file stream #3741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a try-catch block when reading and deserializing the file stream to handle exceptions during file access.
- Wraps file stream reading and deserialization with a try-catch to resolve issue #3716.
- Removes the internal try-catch in DeserializeAsync to let the outer block handle exceptions.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
🥷 Code experts: no user but you matched threshold 10 Jack251970 has most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
📝 WalkthroughWalkthroughThe change adds explicit exception handling to the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant BinaryStorage
participant FileSystem
participant Logger
Caller->>BinaryStorage: TryLoadAsync(defaultData)
BinaryStorage->>FileSystem: Open file stream
alt File access succeeds
BinaryStorage->>BinaryStorage: DeserializeAsync(stream)
BinaryStorage->>Caller: Return deserialized data
else Exception occurs
BinaryStorage->>Logger: Log exception
BinaryStorage->>Caller: Return defaultData
end
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs (1)
91-95
: Minor async library nit – addConfigureAwait(false)
DeserializeAsync
is library/infra code and not UI-context bound; usingConfigureAwait(false)
avoids incidental capturing of a synchronization context:-var t = await MemoryPackSerializer.DeserializeAsync<T>(stream); +var t = await MemoryPackSerializer.DeserializeAsync<T>(stream) + .ConfigureAwait(false);Small but standard for low-level libs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (1)
Flow.Launcher.Infrastructure/Storage/BinaryStorage.cs (1)
69-79
: Here’s a quick inspection of the storage class to confirm its serialization and I/O patterns before updating the comment:#!/bin/bash set -eu # Locate BinaryStorage.cs FILE=$(fd BinaryStorage.cs | head -n1) echo "File: $FILE" echo "------ Head of file (first 50 lines) ------" head -n 50 "$FILE" echo echo "------ Context around DeserializeAsync ------" grep -n -C3 "DeserializeAsync" "$FILE" echo echo "------ Context around SaveAsync ------" grep -n -C3 "SaveAsync" "$FILE"
Resolve #3716.
When reading file stream, we need to wrap it with try-catch sentence.