-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Add missing dispose process to BitPdfReader (#9647) #9661
Add missing dispose process to BitPdfReader (#9647) #9661
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe pull request introduces an asynchronous disposal mechanism for the Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 2
🧹 Nitpick comments (3)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfReader/BitPdfReader.ts (1)
106-112
: Add error handling and canvas cleanup to dispose.While the basic disposal logic is correct, consider these improvements:
- Add try-catch around
pdfDoc.destroy()
to handle potential errors- Clean up canvas elements to prevent memory leaks
public static dispose(id: string) { const config = PdfReader._bitPdfReaders.get(id); if (!config) return; - config.pdfDoc?.destroy(); + try { + config.pdfDoc?.destroy(); + // Clean up canvas elements + const canvas = document.getElementById(config.id); + canvas?.remove(); + } catch (error) { + console.error(`Error disposing PDF reader ${id}:`, error); + } PdfReader._bitPdfReaders.delete(id); }src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfReader/BitPdfReader.razor.cs (2)
8-8
: Consider implementing the full disposable pattern.The class implements IAsyncDisposable but should follow the complete disposable pattern to ensure proper cleanup in all scenarios.
-public partial class BitPdfReader : IAsyncDisposable +public partial class BitPdfReader : IAsyncDisposable, IDisposable
39-39
: Consider making Config initialization thread-safe.The current default initialization might not be thread-safe in all scenarios.
-[Parameter] public BitPdfReaderConfig Config { get; set; } = new(); +[Parameter] public BitPdfReaderConfig Config { get; set; } = new BitPdfReaderConfig();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfReader/BitPdfReader.razor.cs
(5 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfReader/BitPdfReader.ts
(1 hunks)src/BlazorUI/Bit.BlazorUI.Extras/Components/PdfReader/BitPdfReaderJsRuntimeExtensions.cs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build and test
closes #9647
Summary by CodeRabbit
New Features
Refactor
Improvements