fix: convert makeRequest() to async/await with proper error propagation#852
Open
GaneshPatil7517 wants to merge 2 commits intoHSF:mainfrom
Open
fix: convert makeRequest() to async/await with proper error propagation#852GaneshPatil7517 wants to merge 2 commits intoHSF:mainfrom
GaneshPatil7517 wants to merge 2 commits intoHSF:mainfrom
Conversation
- Convert makeRequest() from fire-and-forget fetch to async/await - Add HTTP status check (res.ok) for non-throwing fetch failures - Wrap entire flow including blob/unzip in try/catch - Return Promise<boolean> so callers can properly await the result - Convert loadEvent() in FileLoaderService to async - Convert loadEvent()/loadConfig() in EventDataExplorerDialog to async - Fix loading state: this.loading now correctly set to false after fetch completes instead of immediately Resolves HSF#847
There was a problem hiding this comment.
Pull request overview
This PR fixes error propagation and UI loading-state handling in the phoenix-ui-components file loading pipeline by converting the request flow from “fire-and-forget” promise chains to async/await with centralized error handling.
Changes:
- Refactored
FileLoaderService.makeRequest()toasync/await, addedres.okhandling, and ensured unzip/parse errors are caught and surfaced via aPromise<boolean>result. - Converted
FileLoaderService.loadEvent()to return/propagate the async result. - Updated
EventDataExplorerDialogComponent.loadEvent()/loadConfig()toawaitresults and setloadingtofalseonly after completion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts | Refactors request/unzip flow to async/await with HTTP status checks and boolean error propagation. |
| packages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/event-data-explorer/event-data-explorer-dialog/event-data-explorer-dialog.component.ts | Awaits async loaders to correctly update error/loading and only close on successful completion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts
Show resolved
Hide resolved
packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.ts
Outdated
Show resolved
Hide resolved
- Add urlPath to the HTTP error log for easier debugging - Use Response.arrayBuffer() directly for blob/zip path instead of reading as Blob then converting, avoiding an extra allocation
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
FileLoaderService.makeRequest()had a broken error-reporting pattern:falsesynchronously - thereturn falseat the bottom executed before thefetch()promise ever resolved or rejected.catch()return value was lost -return trueinside.catch()resolved the promise chain, but the synchronousreturn falsehad already executed.then((buf) => this.unzip(buf))chain for blob responses had no.catch(), so a corrupt zip file caused an unhandled promise rejectionfetch()doesn't throw on 404/500 responses, so HTTP errors were silently treated as successesEventDataExplorerDialogComponentsetthis.loading = falseimmediately (synchronously), not after the request completedFix
makeRequest()toasync/awaitwith a singletry/catchwrapping the entire flow (fetch → response parsing → blob/unzip → callback)res.okcheck to catch HTTP error responses (404, 500, CORS failures)Promise<boolean>-trueon error,falseon success - matching the original documented contractloadEvent()inFileLoaderServicetoasyncso it propagates the promiseloadEvent()andloadConfig()inEventDataExplorerDialogComponenttoasyncwithawait, so:this.erroris set after the request completes (not before)this.loadingis set tofalseafter the request completesFiles changed
packages/phoenix-ng/projects/phoenix-ui-components/lib/services/file-loader.service.tspackages/phoenix-ng/projects/phoenix-ui-components/lib/components/ui-menu/event-data-explorer/event-data-explorer-dialog/event-data-explorer-dialog.component.tsTesting
PHYSLITELoaderbuild error inio-options-dialog.component.tsis unrelated to this change (present onmain)- Convert makeRequest() from fire-and-forget fetch to async/awaitResolves #847