HTTP-Requests to one of my apps suddenly take very long and then fail, even though nothing in the code changed

I didn’t change anything in the code for this app for quite some time but suddenly answering HTTP requests takes forever (20-30 seconds) and they often even fail.

These are the errors I’m seeing:

anvil.server.RuntimeUnavailableError: Downlink disconnected

Also:

anvil.server.TimeoutError: Server code took too long

This is weird because the only thing I am doing is this:

  anvil.server.launch_background_task('increment_info_request')
  return app_tables.internal_settings_tmp.get(name="status_of_everything")['value']

It seems like something internal in Anvil changed. Please help!

Hi @tomka,

That sounds like something in your app is grinding your server environment to a halt - possibly by piling up lots of requests, possibly by running out of memory. (Launching enormous numbers of background tasks could do that, if you somehow end up in a recursive loop.)

What I would suggest is scattering some print statements through your code, and working out at what point it’s dying. You could also check what’s happening in your background tasks at the time when it dies (your prints here will turn up in the App Logs).

3 Likes

Hm, I disabled the launching of the background tasks but the issue still seems to persist. The only command that is run now is:

return app_tables.internal_settings_tmp.get(name="status_of_everything")['value']

Could it simply be the amount of requests? There were anywhere from 1000-2500 http requests per day. But this was stable before. I didn’t have issues for weeks, even after adding the launching of background tasks.

I’d appreciate if somebody from the team could look into this issue from your side.

Today it seems like other apps of mine are affected also. Same errors as mentioned in my original post and they also happen simply when I open the app (one that is accessed only a few times per week).