close
Skip to content

fix(services): silence debug console.log on cancelled file upload#8950

Open
selenaalpha77-sketch wants to merge 2 commits intomakeplane:previewfrom
selenaalpha77-sketch:fix/file-upload-silent-cancel
Open

fix(services): silence debug console.log on cancelled file upload#8950
selenaalpha77-sketch wants to merge 2 commits intomakeplane:previewfrom
selenaalpha77-sketch:fix/file-upload-silent-cancel

Conversation

@selenaalpha77-sketch
Copy link
Copy Markdown

@selenaalpha77-sketch selenaalpha77-sketch commented Apr 27, 2026

What

When uploadFile() is intentionally cancelled via cancelUpload(), the catch handler logged the cancellation message with console.log(error.message). In production this surfaces a spurious log line for every user-initiated upload cancellation.

Why

Intentional cancellations are not errors and should not produce console output. The method's own JSDoc states the promise resolves to void; silently returning on cancellation is the correct behaviour.

Change

Replace console.log(error.message) with an early return in the axios.isCancel branch of uploadFile. Non-cancellation errors continue to propagate by re-throwing.

Testing

Cancel an in-progress file upload and confirm no log output appears in the browser console.

Summary by CodeRabbit

  • Bug Fixes
    • Improved file upload error handling to silently process intentionally cancelled uploads without logging errors, while maintaining error reporting for other upload failures.

sriramveeraghanta and others added 2 commits April 6, 2026 20:00
When uploadFile() is intentionally cancelled via cancelUpload(), the
catch handler logged the cancellation message with console.log.  In
production this surfaces a spurious log line for every user-initiated
upload cancellation.  Replace the console.log with an early return so
intentional cancellations are handled silently, consistent with the
behaviour described by the JSDoc comment that says the promise resolves
to void.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sriramveeraghanta
❌ evan


evan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

Updated error handling in the file upload service to silently ignore intentional Axios request cancellations while preserving the original error-throwing behavior for other errors.

Changes

Cohort / File(s) Summary
Axios Cancellation Handling
packages/services/src/file/file-upload.service.ts
Added conditional check to silently return when error is an intentional Axios cancellation, preventing unnecessary error logging for cancelled uploads.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit's whisper on the wind so fleet,
"Cancel that upload—no need to repeat!"
Silent like clover beneath the moon's glow,
Errors now vanish when we say "no."

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: silencing console.log output when file uploads are cancelled, which matches the primary modification in the changeset.
Description check ✅ Passed The description provides clear context (What/Why/Change/Testing sections) and covers the rationale, but lacks the structured template sections like 'Type of Change' checkboxes and explicit test scenarios format.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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.

🧹 Nitpick comments (1)
packages/services/src/file/file-upload.service.ts (1)

41-47: LGTM — silent cancel is consistent with prior resolution semantics.

The previous console.log(error.message) also implicitly returned undefined, so the catch already resolved the promise to undefined on cancel. The explicit return preserves that behavior while removing the noise, which matches the Promise<void> JSDoc. Callers that chain after uploadFile (e.g. updateWorkspaceAssetUploadStatus in apps/web/core/services/file.service.ts) will continue to run on cancel exactly as they did before — no regression introduced here.

Optional nit: since the if branch returns, the else is redundant and can be flattened for slightly cleaner control flow.

♻️ Optional flatten
       .catch((error) => {
         if (axios.isCancel(error)) {
           // Upload was intentionally cancelled; swallow the cancellation silently.
           return;
-        } else {
-          throw error?.response?.data;
         }
+        throw error?.response?.data;
       });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/services/src/file/file-upload.service.ts` around lines 41 - 47, The
catch block in uploadFile currently uses an if/else where the if branch returns
on axios.isCancel(error), making the else redundant; simplify the control flow
by removing the else and unwrapping the throw so that after the early return you
directly throw error?.response?.data; update the catch in file-upload.service.ts
(the axios.isCancel check inside the uploadFile error handler) to reflect this
flattened structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/services/src/file/file-upload.service.ts`:
- Around line 41-47: The catch block in uploadFile currently uses an if/else
where the if branch returns on axios.isCancel(error), making the else redundant;
simplify the control flow by removing the else and unwrapping the throw so that
after the early return you directly throw error?.response?.data; update the
catch in file-upload.service.ts (the axios.isCancel check inside the uploadFile
error handler) to reflect this flattened structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8856b238-4b18-46cc-b1ba-6c3fbac219e8

📥 Commits

Reviewing files that changed from the base of the PR and between a40e064 and 583aefd.

📒 Files selected for processing (1)
  • packages/services/src/file/file-upload.service.ts

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.

3 participants