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

[bug] Model-Manager throws errors when using Nuxt.js (with vue-router) #61

Open
anoack93 opened this issue May 14, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@anoack93
Copy link
Contributor

anoack93 commented May 14, 2021

Describe the bug
Currently, we at diva-e working on a support of the Nuxt.js framework for AEM based on the Vue implementation provided by Mavice.
So we replaced the regular react application in the Weekend-SPA-Example with a similar nuxt setup. The difference here is, that nuxt bootstraps the Vue application internally so we cannot intervent much in this lifecycle.

When importing the aem-spa-page-model-manager package in our nuxt application we get the following error in the browser console:

aem-spa-page-model-manager.js?64bf:1 Uncaught (in promise) Error: ModelClient is undefined. Call initialize first!

This happens as soon as we import anything from your package, even when we are just importing Constants and do nothing else with the modules.

At first this error caused our website to remain blank and no rendering was executed. But by adding some error handling, we were able to avoid this problem and the site was displayed correctly.
In our view this error is strongly related with Issue #60, our current workaround is to disable model routing completly:

meta: [
  { property: 'cq:pagemodel_router', content: 'disabled' }
]

I think in the AEM SPA preview, this property is already set, so this issue only applies for the live page.

Technical Details

The react and vue wknd samples work like this:

  1. Package-Import
  2. Execution of ModelManager.initialize()
  3. Vue/React-Router init

In Nuxt this sequence is a bit different

  1. Package-Import
  2. Vue/React-Router init
  3. Execution of ModelManager.initialize()

Package version

To Reproduce

It should be possible to reproduce this error by using either the react-wknd-spa or vue-wknd-spa (mavice) sample project and create the respective router of the framework before executing ModelManager.initialize

When calling initialize before creating the vue-router, this problem is not present.

Expected behavior

Package import and ModelManager-Init should be independet of the vue router init time. This seems to be a problem caused by #60

Screenshots

Bildschirmfoto von 2021-05-14 10-14-39

@anoack93 anoack93 added the bug Something isn't working label May 14, 2021
@pfauchere
Copy link

pfauchere commented May 14, 2021

Hi, @anoack93 great to see Mavice implement support for Vue.js. You rock! I am wondering if using ModelManager.initializeAsync() [0] could help until #60 is resolved? Anyway, the latter function may become the way to go when initializing the library.

[0] https://github.com/adobe/aem-spa-page-model-manager/blob/master/src/ModelManager.ts#L190

cc @sharanyavinod

@anoack93
Copy link
Contributor Author

I think it does not make a difference to use ModelManager.initializeAsync() because initalize is also based on this function.
Currently we are just disabling the pagemodel-router I think that is okay for now.

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

No branches or pull requests

2 participants