fix: surface server errors instead of silently falling back to offline mode - #1357
Merged
Nitya-003 merged 1 commit intoAug 19, 2026
Conversation
…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.
|
@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. |
Nitya-003
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes Issue #1235:
realCropBatchServiceforwards everycreateBatch/getBatch/updateBatchfailure to the offline store and returns it as success. When the server rejects a submission (400 validation, 404, 500), the user sees a fabricatedTEMP-*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): AddedisNetworkError()helper that checks for the absence oferror.response— Axios network errors (DNS failure, timeout, CORS, connection refused) have noresponseproperty, 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: