Skip to content

fix: surface server errors instead of silently falling back to offline mode - #1357

Merged
Nitya-003 merged 1 commit into
Nitya-003:mainfrom
Kirtan-pc:fix/offline-fallback-only-on-network-errors
Aug 19, 2026
Merged

Nitya-003 merged 1 commit into
Nitya-003:mainfrom
Kirtan-pc:fix/offline-fallback-only-on-network-errors

Conversation

@Kirtan-pc

Copy link
Copy Markdown
Contributor

Summary

This PR fixes Issue #1235: realCropBatchService forwards every createBatch/getBatch/updateBatch failure to the offline store and returns it as success. When the server rejects a submission (400 validation, 404, 500), the user sees a fabricated TEMP-* batch as if registration succeeded, and a later queued re-sync pushes the rejected payload back at the server.

Changes

  • frontend/src/services/realCropBatchService.ts (line 9-11): Added isNetworkError() helper that checks for the absence of error.response — Axios network errors (DNS failure, timeout, CORS, connection refused) have no response property, while server rejections (400, 404, 500) always do.
  • createBatch (line 62-65): Catch block now re-throws server response errors; offline fallback only triggers on genuine network failures.
  • getAllBatches (line 101-104): Same pattern — server errors are re-thrown instead of silently returning only offline batches.
  • getBatch (line 123-126): Same pattern — server errors propagate to the caller.
  • getPublicBatch (line 143-146): Same pattern.
  • updateBatch (line 169-172): Same pattern — server errors propagate instead of being silently queued for offline sync.

Fixes #1235

Copilot Review Feedback

Other suggestions were evaluated but intentionally left unchanged because they are pre-existing issues outside the scope of Issue #1235:

Comment Verdict Reason
Add retry logic with exponential backoff before falling back to offline Out of scope Introduces new retry infrastructure; the immediate fix is to stop treating server rejections as offline successes
Add a global error boundary for API failures Out of scope Pre-existing architectural gap; would require changes across multiple service consumers
Queue failed payloads for manual admin review Out of scope Pre-existing feature gap; introduces new UI and notification requirements beyond a targeted bugfix

…e mode

Previously every API failure (400, 404, 500) in createBatch, getBatch,
getPublicBatch, updateBatch, and getAllBatches was silently caught and
converted into an offline success with a fabricated TEMP-* batch. Server
rejections should never be treated as offline fallbacks.

Added isNetworkError() helper that checks for the absence of error.response
(Axios network errors have no response, while 4xx/5xx do). Each catch block
now re-throws server response errors and only falls back to offline storage
on genuine network failures.
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

@Kirtan-pc is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the merge ready PR is mergeable and has no conflicts label Aug 17, 2026
@Nitya-003
Nitya-003 merged commit 909d80b into Nitya-003:main Aug 19, 2026
15 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge ready PR is mergeable and has no conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop masking server errors with offline-batch success

2 participants