Skip to content

Ionic Framework Lifecycle should wrap with vue ErrorHandler #30374

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

Open
trydofor opened this issue Apr 28, 2025 · 0 comments
Open

Ionic Framework Lifecycle should wrap with vue ErrorHandler #30374

trydofor opened this issue Apr 28, 2025 · 0 comments
Labels

Comments

@trydofor
Copy link

lifecycle should handle error

I diff the lifecycle hooks code between ionic and vue,
it is better to wrap hooks with callWithAsyncErrorHandling as vue do.

no error handle

vue onMounted will hook onErrorCaptured, but onIonViewWillEnter not

- onIonViewWillEnter(async () => {
onMounted(async () => {
  await init();
});
common-class.ts:60 Uncaught (in promise) ApiResultError: Order has expired
    at UseApiRouteFetcher.ts:107:15
    at callHooks (ofetch.03887fc3.mjs:131:15)
    at async $fetchRaw2 (ofetch.03887fc3.mjs:299:7)
    at async $fetch2 (ofetch.03887fc3.mjs:316:15)
    at async fetchTypedResult (typed-fetcher.ts:78:21)
    at async ionicFetchResult (ionic-fetcher.ts:45:12)
    at async init (prepay.vue?t=1745726446418:133:32)
    at async prepay.vue?t=1745726446418:143:7

ionic lifecycle.ts

const wrappedHook = (...args: unknown[]) => {
if (target.isUnmounted) {
return;
}
return args ? hook(...args) : hook();

vue apiLifecycle.ts

https://github.com/vuejs/core/blob/6eb29d345aa73746207f80c89ee8b37ff7b949c9/packages/runtime-core/src/apiLifecycle.ts#L31-L45

const res = callWithAsyncErrorHandling(hook, target, type, args)
// ....
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant