strapi / strapi

🚀 Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable and developer-first.
https://strapi.io
Other
60.59k stars 7.57k forks source link

[4.24.0] Multiple health checks after one action (save/delete) #20216

Closed yanckst closed 2 weeks ago

yanckst commented 2 weeks ago

Bug report

Required System information

┌────────────────────┬──────────────────────────────────────────────────┐
│ Time               │ Fri Apr 26 2024 10:23:25 GMT-0400 (heure avancé… │
│ Launched in        │ 2108 ms                                          │
│ Environment        │ development                                      │
│ Process PID        │ 12120                                            │
│ Version            │ 4.24.0 (node v20.10.0)                           │
│ Edition            │ Community                                        │
│ Database           │ sqlite                                           │
└────────────────────┴──────────────────────────────────────────────────┘

Describe the bug

When saving or deleting a component or a collection, multiples /_health checks are done after each action. On localhost it's 'fine', but in the cloud, resources are limited causing the server to be refreshed at a longer time and causing the server to crash, sometimes.

Steps to reproduce the behavior

  1. Create a strapi app by using yarn create strapi-app my-strapi-project --typescript
  2. When the app is deployed locally, create a first user
  3. When the user is configured, navigate to the Content-type Builder
  4. Create a component with any name
  5. Inside that component create a textbox field with any name
  6. Save the component

Actual behavior

Multiple /_health checks are done in the Network tab and some of them are failing.

Expected behavior

At least one /health check should be done, not multiple ones.

Screenshots

image

2024-04-26_10-33-07

2024-04-26_10-42-36 Notice also that after the delete, I needed to refresh the page to see that the component is deleted.

2024-04-26_10-44-45

Code snippets

Not applicable

Additional context

Question

Is it possible to turn off the /_health checks when doing an action in Strapi?

joshuaellis commented 2 weeks ago

The server restarts when you make changes to your content structure, the health checks are there by design to know when the client can reconnect and work again.

yanckst commented 2 weeks ago

Okay, I understand, but why so many calls for one action?

I was expecting one health check for one action (to check if the server is running and is healthy), but seeing all the same health checks at the same period of time doesn't really make sense. It will impact the performance by doing all those calls.

joshuaellis commented 2 weeks ago

If the server restarts and you make one call it'll fail, how do you propose we then find out it it's restarted?

yanckst commented 2 weeks ago

Before doing any health checks, we log and keep the current request with all the information about the request. We can add this request to a list, DB or something. This list will contain all pending requests.

When doing the health check, we check if there's already a failed request. If so, we try to process the failed request and we repeat this process within a maximum amount of tries. (can be configured in the settings) before starting a new request. I don't know if there's already a retry mechanism for that feature.

If the check is valid, we can continue normally on the app and remove pending requests.

If the check is still invalid and we reach the maximum of tries, we can fallback to the ErrorFlow. It could be showing an error to the user and he might need to redo his actions, etc.

joshuaellis commented 2 weeks ago

How do you plan to keep the pending requests in the DB if the server is restarting and therefore unable to take any request? Sorry I might have misunderstood your proposal.

yanckst commented 2 weeks ago

I don't know how you can do it, but something with a try mechanism/backoff transaction, notification system, etc

Here's the problem with a cloud infrastructure, not a local app.

The app is deployed in the cloud and using a MySQL database.

You can see the health checks is very aggressive. Sometimes the server crashes and we need to restart it.

https://github.com/strapi/strapi/assets/30554401/97485d55-b12f-48a1-add2-ca665d2c4eae

If there's no way for a quick fix, can we disable temporary the health check using a configuration or something?

I didn't find anything in the doc regarding that.

Thanks!

PS I also tested the strapi-beta5 as well and it does the same thing

derrickmehaffy commented 2 weeks ago

You are using development mode in a deployed environment which we do not support.

You should even be able to modify the schema while it's deployed.

Closing this as won't fix since it wouldn't be a problem locally and that's the only place you should be using the content-type builder.