Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught error in async Pilet setup function puts AppShell in LoadingError state. #476

Closed
3 tasks done
EclipseZA opened this issue Feb 17, 2022 · 3 comments
Closed
3 tasks done
Labels
bug Something isn't working core Concerns the piral-core library.
Milestone

Comments

@EclipseZA
Copy link

Bug Report

For more information, see the CONTRIBUTING guide.

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version?
  • Did you perform a search in the issues?

Environment Details and Version

Package: piral-core@0.14.10

Description

When an error occurs in a Pilet's setup function, it should be caught by a wrapping try-catch.
The setup function of a Pilet is allowed to be synchronous or asynchronous. The try-catch catches errors that occur in a synchronous setup function. However, the error slips past the try-catch when it occurs in an async Setup function. The error hits the ErrorBoundary, and because the AppShell is still initializing, it treats it as a LoadingError, when bricks the entire site.

Steps to Reproduce

Successfully caught error for synchronous setup function:

export function setup(app: PiletApi) { throw new Error("Setup error"); }
Error while setting up cx-uex-shell-sandbox-pilet. Error: Setup error
at Object.setup (:1234/$pilet-api/0/index.js?updated=1645095925729:133:9)
at setupSinglePilet (index.35df86.js:97989:28)
at setupPilet (index.35df86.js:98032:16)
at createPilets (index.35df86.js:97384:84)
at evalAll (index.35df86.js:98073:79)
at index.35df86.js:98143:31

Uncaught error for asynchronous setup function:

export async function setup(app: PiletApi) { throw new Error("Setup error"); }
[dev-info] An error occurred in the Piral instance. {type: 'loading', error: Error: Setup error

Expected behavior

Errors in async setup functions should be caught, preventing the Shell from entering a LoadingError state.

Actual behavior

Error is not caught, and Shell enters a LoadingError state.

Possible Origin / Solution

In src/framework/piral-base/src/setup.ts:
setupSinglePilet does not await app.setup(api).
Try-catch is exited before error occurs.

@EclipseZA EclipseZA added the bug Something isn't working label Feb 17, 2022
@FlorianRappl FlorianRappl added core Concerns the piral-core library. in-implementation The item is currently being implemented. labels Feb 17, 2022
@FlorianRappl FlorianRappl added this to the 0.14.11 milestone Feb 17, 2022
FlorianRappl added a commit that referenced this issue Feb 17, 2022
@FlorianRappl FlorianRappl added in-testing The item is already out in preview and can be tested. and removed in-implementation The item is currently being implemented. labels Feb 17, 2022
@FlorianRappl
Copy link
Contributor

This is available in develop and should be out in the next version in about 25-30 min.

@EclipseZA
Copy link
Author

Awesome, thanks for the speedy fix.

@FlorianRappl FlorianRappl removed the in-testing The item is already out in preview and can be tested. label Feb 17, 2022
@FlorianRappl
Copy link
Contributor

This is working as intended. Will be released with the 0.14.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Concerns the piral-core library.
Projects
None yet
Development

No branches or pull requests

2 participants