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

When strapi-prometheus plugin is disabled and strapi-prometheus.metrics middleware has been added, strapi app doesnt start #9

Closed
lrasata opened this issue Nov 23, 2022 · 3 comments · Fixed by #10
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@lrasata
Copy link

lrasata commented Nov 23, 2022

Describe the bug
When strapi-prometheus plugin is disabled and strapi-prometheus.metrics middleware has been added, strapi app doesnt start

To Reproduce
Steps to reproduce the behavior:

  1. Install strapi-prometheus : 'yarn add strapi-prometheus'
  2. Add plugin config in config/plugins.js as shown here
  3. Set enabled attribute to false for strapi-prometheus
  4. Add the middleware plugin::strapi-prometheus.metrics in config/middlewares.js
  5. Run yarn develop

Actuall outcome in logs

$ strapi develop
[2022-11-24 09:51:14.764] debug: ⛔️ Server wasn't able to start properly.
[2022-11-24 09:51:14.765] error: Invalid middleware configuration. Expected Array<string|{name?: string, resolve?: string, config: any}.
Error: Invalid middleware configuration. Expected Array<string|{name?: string, resolve?: string, config: any}.

Expected behavior
App should starts normally.
the expectation is : if an external plugin has a middleware declared in config/middlewares.js, if that external plugin is disabled, the middleware of the plugin should not be automatically added...

Environment (please complete the following information):

  • OS: MacOS Ventura 13.0
  • Browser: Chrome
  • Strapi: v4.4.5
  • strapi-prometheus: 1.1.1
@XanderD99 XanderD99 added bug Something isn't working good first issue Good for newcomers labels Nov 24, 2022
@XanderD99
Copy link
Owner

Thanks for reporting this issue. This wasn't something I thought of when creating the package, I'll get this fixed asap.

@XanderD99 XanderD99 linked a pull request Nov 27, 2022 that will close this issue
@XanderD99
Copy link
Owner

@lrasata I made some changes. The middleware is now injected automatically when the plugin is loaded, so you don't need to manually add it to your middleware.js this also prevents your error of middleware not found from happening whenever the plugin is disabled.

Upgrade to version 1.2.0 for these changes to take effect.

@lrasata
Copy link
Author

lrasata commented Nov 27, 2022

@lrasata I made some changes. The middleware is now injected automatically when the plugin is loaded, so you don't need to manually add it to your middleware.js this also prevents your error of middleware not found from happening whenever the plugin is disabled.

Upgrade to version 1.2.0 for these changes to take effect.

Thanks very much! will have a try

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

Successfully merging a pull request may close this issue.

2 participants