Internal Server Errors with various functions

Over the past 2 days I have been getting various Internal server errors on server function calls and these are existing functions that have been working without issue. These are some of the error codes I got just this morning. They are all from the same function.

anvil.server.InternalError: Internal server error: 1b6e311aaed8
anvil.server.InternalError: Internal server error: 7439f91f7a20
anvil.server.InternalError: Internal server error: 1920eec816c6

I have a few different server functions that attempt various things like adding rows or deleting rows. Some of the functions using the @anvil.tables.in_transaction decorator and I noticed the functions started to fire off X times before failing with a timeout error so I broke them down and added try catches to narrow down the issue. Its also inconsistent, between the different errors and then occasionally it just works first try.

here is an example of one of the failing functions.

@anvil.server.callable(require_user=True)
@anvil.tables.in_transaction
def delete_items(row):
  log_warning('deleting item for {}:  {}'.format(row['package']['part_number'], row['part_number']))
  for record in app_tables.packages_item_documents.search(item=row):
    record.delete()
  for record in app_tables.packages_item_similarities_differences.search(item=row):
    record.delete()
  
  app_tables.packages_items.get_by_id(row.get_id()).delete()

I have tried using relaxed transactions, putting each table change into its own transaction, and removing the transaction altogether but I still keep running into internal server errors.

Is it possible something is messed up in this apps DB?

1 Like

Hi and welcome to the forum.

Internal errors shouldn’t happen. They are a symptom that something is wrong in the server and, especially if they start popping up on functions that used to work, the Anvil team should have a look at them. They do keep an eye on the forum, but I would send an email to the support to make sure they didn’t miss this.

One little comment about that last line: isn’t that equivalent to row.delete()?

1 Like

Welcome to the forum!

Those errors are pretty generic, a sign that something went wrong, usually deeper than your code. The error codes you’re seeing will correspond to reports in system logs that the Anvil staff can inspect. We can make guesses, but in general you’re going to need Anvil staff to take a look. A support email isn’t unreasonable to ask about those error codes, along with information about time, day, application id, etc.

Edit: Ninja’d by Stefano while I was typing!

You are correct. That’s definitely something I can fix in this particular function.

Hi folks,

No need to jump to an email to support@ - this forum is the right place to go in the first instance! (@stefano.menci can go straight to private email, because his company has a support plan :slight_smile: ) We keep an eye on the forum, and will be looking into this.

If you encounter an internal error code, that’s usually enough for us to investigate. If we need extra details from you, we’ll reply to ask for them - if the relevant information is private, we might request an email to support@, but it’s a good idea to start here first.

3 Likes