Skip to content

fix: properly abort XMLHttpRequest in SaveToWebdavModal#37648

Open
aegloist wants to merge 1 commit into
RocketChat:developfrom
aegloist:fix/webdav-modal-memory-leak
Open

fix: properly abort XMLHttpRequest in SaveToWebdavModal#37648
aegloist wants to merge 1 commit into
RocketChat:developfrom
aegloist:fix/webdav-modal-memory-leak

Conversation

@aegloist
Copy link
Copy Markdown

@aegloist aegloist commented Nov 30, 2025

Proposed changes

This PR fixes a memory leak in the SaveToWebdavModal component where XMLHttpRequest instances were not being properly aborted on component unmount.

The Problem

The current implementation has an incorrect useEffect cleanup that doesn't actually call the abort method:

useEffect(() => fileRequest.current?.abort, []);

Summary by CodeRabbit

  • Bug Fixes
    • Improved Save to WebDAV modal stability by ensuring file requests are properly cancelled when closing the dialog, preventing potential issues with incomplete cleanup.

✏️ Tip: You can customize this high-level summary in your review settings.

@aegloist aegloist requested a review from a team as a code owner November 30, 2025 18:43
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 30, 2025

⚠️ No Changeset found

Latest commit: ca90e68

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Nov 30, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 30, 2025

Walkthrough

A single file change modifying the cleanup behavior of a React effect hook. The fileRequest abort handling is changed from returning an abort function to explicitly invoking fileRequest.current?.abort() in a dedicated cleanup function, ensuring proper execution during unmount.

Changes

Cohort / File(s) Summary
Effect cleanup refactor
apps/meteor/client/views/room/webdav/SaveToWebdavModal.tsx
Changed the cleanup behavior of the fileRequest effect from returning an abort function to explicitly invoking fileRequest.current?.abort() in a dedicated cleanup function to ensure the abort is executed during unmount.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A cleanup so fine, a fix tried and true,
The abort now promised when effects are through,
No more shall requests linger and wait,
For the rabbit ensures each teardown's fate! 🎀

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a proper cleanup function to abort XMLHttpRequest in the SaveToWebdav component to fix a memory leak.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@aegloist aegloist changed the title Fix: Add proper cleanup function to abort XMLHttpRequest in SaveToWeb… fix: properly abort XMLHttpRequest in SaveToWebdavModal Nov 30, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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)
apps/meteor/client/views/room/webdav/SaveToWebdavModal.tsx (1)

85-86: Consider converting error to string for toast message.

The error object is passed directly to dispatchToastMessage. If error is an Error instance, it may not display properly.

Apply this diff to ensure proper error message display:

 				} catch (error) {
-					return dispatchToastMessage({ type: 'error', message: error });
+					return dispatchToastMessage({ type: 'error', message: error instanceof Error ? error.message : String(error) });
 				} finally {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e1c634a and ca90e68.

📒 Files selected for processing (1)
  • apps/meteor/client/views/room/webdav/SaveToWebdavModal.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/room/webdav/SaveToWebdavModal.tsx
🔇 Additional comments (1)
apps/meteor/client/views/room/webdav/SaveToWebdavModal.tsx (1)

60-60: LGTM! Proper cleanup function now invokes abort.

The fix correctly returns a cleanup function that invokes fileRequest.current?.abort() during component unmount, preventing memory leaks from in-flight XMLHttpRequest instances.

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.

2 participants