Skip to content

fix(api): suppress error toast during silent requests and update backend startup#110

Merged
jpdevhub merged 1 commit into
jpdevhub:mainfrom
BHOGALA-SRIKA:fix/backend-startup-script
Jun 22, 2026
Merged

fix(api): suppress error toast during silent requests and update backend startup#110
jpdevhub merged 1 commit into
jpdevhub:mainfrom
BHOGALA-SRIKA:fix/backend-startup-script

Conversation

@BHOGALA-SRIKA

@BHOGALA-SRIKA BHOGALA-SRIKA commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Closes #108

This PR fixes Issue #108 by ensuring that network requests marked as silent do not trigger error toasts.

Also included an update to start-backend.bat to ensure a smoother local development experience.

Checklist

  • npm run lint passes with no errors
  • npm run build compiles without TypeScript errors
  • No .env files, API keys, secrets, model weights, or __pycache__ in this diff

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for API requests to better identify and communicate connection-related issues with clearer messages to users. Added support for silently suppressing error notifications on specific API calls when needed, providing more flexible control and better handling of error presentation throughout the application.

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

@BHOGALA-SRIKA is attempting to deploy a commit to the karan3431's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid input: expected object, received boolean at "reviews.auto_review"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0702f2ad-ea07-4c06-8490-15d63f25467c

📥 Commits

Reviewing files that changed from the base of the PR and between 357adbd and d0676e2.

📒 Files selected for processing (1)
  • src/lib/api.ts

📝 Walkthrough

Walkthrough

In src/lib/api.ts, the safeFetch catch block's condition for showing the "Unable to connect to the server" toast is updated from a TypeError-only check to also match errors whose string representation includes "fetch", while still gating on !options?.silent.

Changes

safeFetch Silent Flag for Fetch Errors

Layer / File(s) Summary
safeFetch catch: silent + fetch error detection
src/lib/api.ts
The single-line condition now combines !options?.silent with (error instanceof TypeError || error.toString().includes("fetch")), so background calls passing { silent: true } suppress the connection error toast for both TypeError and other fetch-related errors.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • jpdevhub/FreshScanAi#97: Modifies safeFetch in src/lib/api.ts to conditionally suppress the connection/fetch toast via options?.silent, directly overlapping with this change's logic.

Suggested labels

size/level: easy

Suggested reviewers

  • jpdevhub

Poem

🐇 A silent hop through offline night,
No toast to startle, all is right.
The fetch may fail, the network gone,
But freshness scores still carry on.
silent: true — the bunny's delight! 🌿

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning PR objectives note unrelated changes to ci.yml, README.md, and start-backend.bat were incorrectly included despite the core fix being limited to src/lib/api.ts. Rebase onto main to remove out-of-scope changes to ci.yml, README.md, and start-backend.bat; keep only the 3-line safeFetch fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 mentions both api error toast suppression (main change in raw_summary) and backend startup (mentioned in PR objectives but not reflected in raw_summary of actual changes).
Linked Issues check ✅ Passed The safeFetch fix correctly addresses Issue #108's core requirement to respect silent flag for TypeError network errors, directly implementing the stated objective.

✏️ 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.

@jpdevhub

Copy link
Copy Markdown
Owner

Thank you for the fix in src/lib/api.ts—that logic is exactly what we needed to silence the toast!

However, I cannot merge this PR because your branch is severely out of sync and contains unrelated, destructive changes. Your commit is attempting to:

Delete a critical ci.yml rate-limiting fix we just merged to main.
Delete all the UI badges from the README.md.
Please run git fetch upstream && git rebase upstream/main (or sync your fork) and remove all changes to ci.yml, README.md, and scripts/start-backend.bat. This PR should ONLY contain the 3 lines of code changed in src/lib/api.ts. Let me know when the diff is clean!

@BHOGALA-SRIKA

Copy link
Copy Markdown
Contributor Author

Okay, I apologize for the messy commits and the accidental changes to ci.yml and README.md. I will check into it.

@BHOGALA-SRIKA

Copy link
Copy Markdown
Contributor Author

I have rebased my branch onto the latest upstream/main and cleaned up the PR. All accidental changes to ci.yml, README.md, and the backend scripts have been removed. The PR now contains only the intended fix for suppressing silent error toasts in src/lib/api.ts. You can look into the FilesChanged Tab. Thank you

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fresh-scan-ai Ready Ready Preview, Comment Jun 22, 2026 8:22am

@jpdevhub jpdevhub left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for contributing

@jpdevhub jpdevhub merged commit 9ee6ae4 into jpdevhub:main Jun 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Background api.submitScan throws server error toast in full offline mode

2 participants