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

enhanceApp does not always await all promises on page refresh #2074

Closed
1 task done
staghouse opened this issue Dec 9, 2019 · 2 comments · Fixed by #2075 · May be fixed by adamlaska/osmos-cosmos-sdk#5
Closed
1 task done

enhanceApp does not always await all promises on page refresh #2074

staghouse opened this issue Dec 9, 2019 · 2 comments · Fixed by #2075 · May be fixed by adamlaska/osmos-cosmos-sdk#5
Labels
has PR Has a related PR type: enhancement Request to enhance an existing feature

Comments

@staghouse
Copy link

  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

  1. Create enhanceApp.js
  2. Add 1 or more Promises
  3. Store promises in Vue.prototype, siteData, etc, for example, Vue.prototype.myPromisedData = await myPromiseFunction(), though it doesnt matter if its a function or try/catch with storage on success
  4. Retrieve, for example, this.myPromisedData in a component

What is expected?

this.myPromisedData should always return what data is expected

What is actually happening?

The data returns undefined/promise pending/sometimes loads/only returns some promises. Its all wildly inconsistent other than the first promise returned has a higher chance of returning valid.

This seems to be a local-only issue as it does not happen on my production server. Could it be related to the HMR?

Other relevant information

  • Output of npx vuepress info in my VuePress project:
  System:
    OS: macOS 10.15.1
    CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
  Binaries:
    Node: 12.8.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.10.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 78.0.3904.108
    Firefox: 71.0
    Safari: 13.0.3
  npmPackages:
    @vuepress/core:  1.0.3 
    @vuepress/theme-default:  1.0.3 
    vuepress: ^1.0.3 => 1.0.3 
  npmGlobalPackages:
    vuepress: Not Found
@meteorlxy
Copy link
Member

meteorlxy commented Dec 9, 2019

Currently, enhanceApp does not handle async functions:

appEnhancers.forEach(enhancer => {
if (typeof enhancer === 'function') {
enhancer({ Vue, options, router, siteData, isServer })
}
})

Maybe something like this, or use Promise.all() ?

appEnhancers.forEach(async enhancer => { 
  if (typeof enhancer === 'function') { 
    await enhancer({ Vue, options, router, siteData, isServer }) 
  } 
}) 

@meteorlxy meteorlxy added the type: enhancement Request to enhance an existing feature label Dec 9, 2019
@staghouse
Copy link
Author

staghouse commented Dec 9, 2019

As a note, I have tried Promise.all as well, with some variation in consistency: Either all promises resolve, or none.

Edit: Both in enhanceApp.js and in app.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has PR Has a related PR type: enhancement Request to enhance an existing feature
Projects
None yet
2 participants