Skip to content

fix(import): prevent infinite calls to /getImportFileData#38573

Open
PurnenduMIshra129th wants to merge 9 commits into
RocketChat:developfrom
PurnenduMIshra129th:infiniteApiCall
Open

fix(import): prevent infinite calls to /getImportFileData#38573
PurnenduMIshra129th wants to merge 9 commits into
RocketChat:developfrom
PurnenduMIshra129th:infiniteApiCall

Conversation

@PurnenduMIshra129th
Copy link
Copy Markdown

@PurnenduMIshra129th PurnenduMIshra129th commented Feb 9, 2026

Proposed changes (including videos or screenshots)

This pull request fixes a problem in the import workflow.
Currently, if a user uploads the wrong file type (for example, a PDF instead of a Slack users CSV), the system blocks the file but still keeps calling the getImportFileData API repeatedly. The API response stays as {"waiting": true, "success": true}, which causes endless requests in the browser network tab.
With this change:

  • The import process will stop making repeated calls when the file type is invalid.
  • The getImportFileData endpoint will only be called once in this case.
  • Users will see a clear error message instead of hidden background requests.

Issue(s)

#38499 (comment)

Steps to test or reproduce

Already a issue is create - #38499 (comment)

Further comments

Alternatives also considered as prevent the file in client side directly so that it won't able to call the api , first logic fail is better than after which causes this issue . Example - if user is selecting a specifc file but upload other files then he should not be able to hit the api , we will break it on client.

Summary by CodeRabbit

  • Bug Fixes
    • Improved import preparation stability by replacing unbounded retries with a bounded, configurable retry mechanism (default 60 attempts) that waits 1 second between attempts and surfaces a timeout error once the limit is reached, allowing faster and more predictable failure handling.

@PurnenduMIshra129th PurnenduMIshra129th requested a review from a team as a code owner February 9, 2026 19:48
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 9, 2026

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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 9, 2026

CLA assistant check
All committers have signed the CLA.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 9, 2026

⚠️ No Changeset found

Latest commit: aefb40c

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 9, 2026

Walkthrough

waitFor in the import preparation page now accepts a new maxRetries parameter (default 60) and tracks attempts; it retries the predicate up to maxRetries times with 1s delays and rejects with a timeout error if the limit is reached.

Changes

Cohort / File(s) Summary
Retry Logic Enhancement
apps/meteor/client/views/admin/import/PrepareImportPage.tsx
Refactored waitFor to add maxRetries (default 60) and an attempts counter. Predicate checks retry with 1s delays up to maxRetries; on exceeding the limit the promise rejects with a timeout error, replacing unbounded retries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hop and count each hopeful try,

Sixty beats beneath the sky,
One-second pauses, patient and bright,
A timeout tolls if none take flight,
I nibble logs and cheer the new retry.

🚥 Pre-merge checks | ✅ 3
✅ 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 directly addresses the main issue fixed in this PR—preventing infinite API calls to /getImportFileData by implementing bounded retries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


No actionable comments were generated in the recent review. 🎉

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e181c0 and 07e56d6.

📒 Files selected for processing (1)
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

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: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/client/views/admin/import/PrepareImportPage.tsx`:
- Around line 27-41: The current waitFor implementation uses a hardcoded
maxRetries = 5 which is too low and causes legitimate long-running imports to
error; update waitFor to accept a configurable maxRetries parameter (or
timeout/ms interval) and replace the hardcoded maxRetries reference so callers
can pass different thresholds from getImportFileData and
getCurrentImportOperation (e.g., 60–120 attempts), and keep the default high
enough to avoid premature failures; also ensure the reject message still
includes the attempted limit and that call sites (getImportFileData,
getCurrentImportOperation) are updated to pass appropriate retry values.
🧹 Nitpick comments (1)
apps/meteor/client/views/admin/import/PrepareImportPage.tsx (1)

86-108: The error surfaced to the user on retry exhaustion is generic — consider a more specific message for the invalid-file case.

When waitFor rejects after 5 attempts, the catch block at line 105 passes the raw Error("waitFor: predicate not satisfied after 5 attempts") to handleError. This internal message will likely be confusing to end users. A message like "The uploaded file could not be processed. Please ensure the file format is valid." would be far more actionable.

Proposed improvement
 		} catch (error) {
-			handleError(error, t('Failed_To_Load_Import_Data'));
+			handleError(t('Invalid_import_file_type_or_processing_timeout'));
 			router.navigate('/admin/import');
 		}

(You'd need a corresponding translation key, or use an existing one that fits.)

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13433b1 and 7e181c0.

📒 Files selected for processing (1)
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🧰 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/admin/import/PrepareImportPage.tsx
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2026-02-04T12:09:05.769Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 38374
File: apps/meteor/tests/end-to-end/apps/app-logs-nested-requests.ts:26-37
Timestamp: 2026-02-04T12:09:05.769Z
Learning: In E2E tests at apps/meteor/tests/end-to-end/apps/, prefer sleeping for a fixed duration (e.g., 1 second) over implementing polling/retry logic when waiting for asynchronous operations to complete. Tests should fail deterministically if the expected result isn't available after the sleep.

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread apps/meteor/client/views/admin/import/PrepareImportPage.tsx
@TheRazorbill
Copy link
Copy Markdown
Contributor

Hi!

  1. PR Title: Please rename the PR to fix: Show error message when SMTP is not configured. The current format is triggering the Invalid PR Title label.

How to fix: You can change the title by clicking the "Edit" button at the top of this page (to the right of the current title or in the checks in the commit rightside). Follow the Conventional Commits format.

  1. CLA: It seems you've signed it, but it's still showing as pending.

How to fix: Try clicking the 'recheck' link in the CLAassistant comment. You can also go to the checks list at the bottom of the page, click on "license/cla", and ensure everything is authorized.

Once these are green, we can look into the linting and logic issues!

@PurnenduMIshra129th PurnenduMIshra129th changed the title fix:Infinite api call of api /getImportFileData fix(import): prevent infinite calls to /getImportFileData Feb 10, 2026
@PurnenduMIshra129th
Copy link
Copy Markdown
Author

hi @TheRazorbill can u tell how this pr will be merged , should i have to ping in some group , why my pr only 3 successfull checks and tests done flow is not running ? what am i doing wrong ?

@TheRazorbill
Copy link
Copy Markdown
Contributor

Hi @PurnenduMIshra129th,

The "waiting for status" is normal; a maintainer needs to manually approve the workflow for security.

For more visibility, you can share your PR link in the #landing-the-first-merged-pr channel on the open server. Some maintainers look there!

Note: No need to tag people. Contribution guides and issue tagging are currently being improved by the team, so it might take a bit of time, but work is in progress.

@PurnenduMIshra129th
Copy link
Copy Markdown
Author

thanks for your support to clearing the points

@Rohit544
Copy link
Copy Markdown

Kindly please assign this issue to me please I want work with it

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.

5 participants