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

Make plugins async #915

Open
MarijnMensinga opened this issue Feb 6, 2023 · 6 comments
Open

Make plugins async #915

MarijnMensinga opened this issue Feb 6, 2023 · 6 comments
Labels

Comments

@MarijnMensinga
Copy link

For the benefit of bootstrapping plugins it is usefull to make plugins load async.

nitro/src/runtime/app.ts

Lines 89 to 91 in ed3a480

for (const plugin of plugins) {
plugin(app);
}

Can someone explain to me if there is a good reason to load plugins synchronously?

@Harm-Nullix

This comment was marked as off-topic.

@ruslankonev

This comment was marked as off-topic.

@pi0 pi0 added enhancement New feature or request discussion labels Aug 6, 2023
@fabis94

This comment was marked as off-topic.

@pi0
Copy link
Member

pi0 commented Sep 27, 2023

This issue is on track and I might have some ideas to support it in a nonbreaking change version with slight behavior-only changes. In the meantime, please consider issue 👍🏼 on main issue if you also want this feature 🙏🏼

@robertpatrick
Copy link

It all seems relatively straightforward. The last step is the only tricky one

  • Convert createNitroApp into an async function that returns Promise<NitroApp>
  • Change the plugin invocations to catch the return value from the plugin
  • If the return value is a Promise, call await Promise.all([pluginPromise])
  • change the export for nitroApp so that it is initialized when the promise is resolved.

This will ensure that the semantics of order and waiting for one plugin to finish before the next runs are retained. I guess I don't understand why this is complicated...

@pi0
Copy link
Member

pi0 commented Oct 17, 2023

Sadly, it is not that straightforward without behavior changes / overhead because not all nitro presets are compatible with an async entry today but thanks for your feedback dear @robertpatrick.

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

Successfully merging a pull request may close this issue.

6 participants