fix: avoid misleading failure when metadata delete times out (DHIS2-15823) - #986
fix: avoid misleading failure when metadata delete times out (DHIS2-15823)#986karolinelien wants to merge 5 commits into
Conversation
…5823)
A long-running delete (eg. a Category Combo whose category option combos
take a while to cascade-delete) can exceed a proxy/connection timeout. The
client request is aborted or gets a gateway timeout while the backend keeps
processing and completes the delete, but the UI showed a hard "Failed to
delete" error - misleading the user into thinking nothing happened.
- Add isMaybeStillProcessingError() to detect network/aborted errors and
408/502/503/504 gateway responses where the operation may still complete
server-side.
- Show a softer "The deletion may still be in progress" warning in that case,
prompting the user to refresh before retrying.
- Fix the {{messages}} placeholder in the failure message, which was never
interpolated and always rendered empty; now shows the backend message.
AI Assisted
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for dhis2-maintenance-app-beta ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Detect gateway timeouts (408/502/503/504) even when the proxy returns a
non-JSON body: app-runtime only populates details.httpStatusCode for DHIS2
JSON responses, so fall back to parsing the status from the error message
("...statusText (504)"). Previously the 502/503/504 branch never fired
against a real reverse-proxy timeout - the headline case for this fix.
- Drop redundant type cast and optional chaining on the non-optional
FetchError.details field (extract getHttpStatusCode helper).
- Mark the status-code lookup table readonly; drop redundant cast in the test.
- Consolidate the two near-identical NoticeBox blocks into one to remove
duplicated JSX.
- Add tests for proxy timeouts (status only in message) and for an unknown
error with no status code.
AI Assisted
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Ran two independent reviews (correctness + SonarQube-style quality) and pushed fixes. Material correctness fix (found in review): the original 502/503/504 detection relied on Quality fixes:
AI Assisted |
Convert MAYBE_STILL_PROCESSING_STATUS_CODES to a ReadonlySet and use .has() instead of Array.includes(), resolving the SonarCloud code smell that failed the quality gate. AI Assisted Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Reword the timeout warning to "The request timed out. The operation may
still be processing in the background, refresh to confirm."
- Add DeleteAction.spec.tsx covering the timeout ("still processing") branch
and the hard-failure branch (backend error messages shown), giving the new
delete-error handling test coverage.
AI Assisted
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Change the title to 'The operation may still be in progress'. AI Assisted Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
edcb1ec to
fbd56fd
Compare
|



Summary
Fixes DHIS2-15823.
A long-running metadata delete — e.g. a Category Combo whose category option combos take a while to cascade-delete — can exceed a proxy/connection timeout. The client request is aborted or receives a gateway timeout while the backend keeps processing and completes the delete, but the UI showed a hard "Failed to delete" error, misleading the user into thinking nothing happened (and prompting duplicate delete attempts).
The original ticket described this in the legacy maintenance app ("undefined was not deleted"). That app is gone, but the same behaviour is still present in this app in a different form — this PR addresses it here.
Changes
isMaybeStillProcessingError()to detectnetwork/abortedfetch errors and408/502/503/504gateway responses, where the operation may still be completing server-side.{{messages}}placeholder in the failure message, which was never interpolated and always rendered empty; it now shows the backend message.Notes / limitations
Testing
yarn check-types✅yarn d2-style check(eslint + prettier + tsc) ✅src/lib/errors/errors.spec.ts(13 cases) ✅categoryCombos/List.spec.tsxsmoke test ✅AI Assisted
@