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

extendRoutes does not support async functions correctly #8037

Closed
rchl opened this issue Sep 9, 2020 · 3 comments
Closed

extendRoutes does not support async functions correctly #8037

rchl opened this issue Sep 9, 2020 · 3 comments

Comments

@rchl
Copy link

rchl commented Sep 9, 2020

Versions

  • nuxt: v2.14.0
  • node: ex: v12.18.2

Reproduction

https://github.com/rchl/nuxt-issue-extendRoutes-async

Steps to reproduce

  1. Have two modules using this.extendRoutes
  2. Have earlier module call it with an async function

What is Expected?

The second module receives a list of extended routes.

What is actually happening?

Error: routes.push is not a function.
The second module crashes on trying to modify routes as it receives a promise rather than an array.

Additional info

chainFn used by extendRoutes doesn't resolve chained functions so if one of the modules uses async function then it will pass unresolved promise to the next module.

It happens to work if there is only one module using extendRoutes and passing async function to it as then it's awaited by the code that triggers chained functions in the first place.

@pi0
Copy link
Member

pi0 commented Sep 10, 2020

Hi @rchl. Should be resolved with v2.14.5 please tell if wasn't properly working for your use case

@rchl
Copy link
Author

rchl commented Sep 10, 2020

Thanks.

I have a workaround for nuxt-i18n (using CommonJS require rather than ESImports) and I won't be switching back to the old way as that wouldn't be compatible with older versions.

@pi0
Copy link
Member

pi0 commented Sep 10, 2020

Indeed making sense for backward compatibility :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants