fix(GeolocationEditor): handle missing geo-data files gracefully#438
Open
Laqoore wants to merge 1 commit into
Open
fix(GeolocationEditor): handle missing geo-data files gracefully#438Laqoore wants to merge 1 commit into
Laqoore wants to merge 1 commit into
Conversation
When geo-data JSON files are unavailable (e.g. 404 in SeaTable external
apps), both primary and fallback fetch chains now always resolve rather
than reject, preventing unhandled promise rejections that left the
editor stuck in an infinite loading state or caused TypeError crashes
in render methods.
Changes:
- getLocationData / getCountryData: add .catch(() => null) to the local
fallback so the promise always resolves; fix missing `|| {}` guard on
config destructuring in getCountryData
- transLocationData / transCountryData (mb-editor): guard against null/
undefined input, return [] instead of crashing on null.children
- ProvinceEditor, ProvinceCityEditor, LocationEditor (pc + mb): add
.catch() handlers so isLoadingData is cleared on fetch failure, and
guard .children access with || [] to prevent 'Cannot read properties
of undefined' crashes
- initLocationSelecting: guard .children with || [] and add name truthy
check before calling .includes() so corrupt geo-data entries do not
crash the editor
Co-Authored-By: Paperclip <noreply@paperclip.ing>
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.
Problem
In SeaTable external apps (Universal Apps), geo-data JSON files are fetched from a path derived from
mediaUrl, which in the external app context resolves to the app's own URL (e.g./external-apps/<uuid>/geo-data/). These files don't exist there, causing 404 errors.404s observed:
/external-apps/<uuid>/geo-data/en-region-location.json→ 404/external-apps/<uuid>/geo-data/cn-location.json→ 404/external-apps/<uuid>/geo-data/cn-region-location.json→ 404This produces white screens with:
Closes #437
Root Causes
getLocationData/getCountryData: The local fallbackfetch('./geo-data/...')has no.catch(), so when both fetches fail the returned promise rejects. Component.then()handlers never run.getCountryData:const { mediaUrl = '', server = '' } = config;throws ifconfigisnull/undefined(unlikegetLocationDatawhich already usesconfig || {}).PC editors (
ProvinceEditor,ProvinceCityEditor,LocationEditor): No.catch()ongetData()call;this.locations.childrenaccessed without null guard;province.name.includes(...)called without checkingprovince.nameis defined.MB editors: Missing
.catch()handlers and null guards intransLocationData/transCountryDataand functional components.Fix
.catch(() => null)so the outer.then(res => { const data = res || {}; })always runsconfig || {}added togetCountryDatagetData().then(data => ...)calls get.catch(() => setLoadingFalse)(this.locations.children || [])andprovince.name &&guards added throughouttransLocationData(null)returns[]instead of crashing on.children