Internal Anvil error?

Anyone else seeing this currently?
anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: dba9352773

Update: It’s working now, 15 minutes later.

I’ve continued to get this intermittently today, though. Most recently: ExecutionTerminatedError: Server code exited unexpectedly: 51a99b36de

The latest: anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: 629b6c0a2b

:slightly_frowning_face:

anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: e7c67b522b

I also get the error so often, but it doesn’t affect my apps much. Closing and opening the app again fixes it.

Does it affect yours?

I’ve gotten it probably 50 times today while manually testing my app as I code. Roughly every other server call. So it gets very frustrating. And it’s not a particular server call. It seems random which server functions cause it, and the same server function can trigger an error but then run ok a few seconds later.

Does the error point to a specific line of code in your case? Sometimes it does

It points to the line in my client/form code that called the server function but gives no information about where in the server function the error occurred.

edit: Just now it’s happening repeatedly so that I can’t run any server functions. (Latest: anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: dad33252aa) I hate to complain as a free user. I’m thinking of upgrading to the paid plan (which I always intended to do but hoped to wait until I got closer to releasing the app into production) to get this addressed, but I’m sure that is now how Anvil is intending to operate: that the basic functionality is not reliable unless you are on a paid plan.

Is it the same server function? Do you import anything special in the server?

Hi @hugetim,

Tracing those error codes, it looks like your process was attempting to do something it’s not supposed to do, and is getting shot down by our sandbox (which is pretty strict on the Free plan for obvious reasons). The particular system call is IO-related - are you trying to read or write a lot of data, or in a way that might be considered unusual?

Can you try putting some print statements into your code to narrow down what call it’s bailing out on? (If it’s a library call, that is particularly suspicious.)

Thanks so much. I’m reading and writing to Data Tables but not very much. If I’m doing it in unusual ways, it’s out of ignorance, so it’s hard to say. :slightly_smiling_face: I will try narrowing down the location with print statements.

Ok, I think I traced it to this ugly code:

  old_proposals = (r for r in app_tables.proposals.search(current=True)
                   if len(app_tables.proposal_times.search(current=True, proposal=r))==0)
  for row in old_proposals:
    row['current'] = False

I can try rewriting as a loop rather than a comprehension. But maybe that won’t solve it if the problem is something to do with two queries at the same time?

Update: I rewrote the code to eliminate the nested SearchIterators and I haven’t had the error recur yet.

Alas, I continue to get the error. Once (ExecutionTerminatedError: Server code exited unexpectedly: 6da0c7fdc6) at this code in a server function:

old_prop_times = [r for r in app_tables.proposal_times.search(current=True, jitsi_code=None)
                  if r['expire_date'] < now]
for row in old_prop_times:
  row['current'] = False
  proposals_to_check.add(row['proposal'])

Once (anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: 170fb6b5ad) from this:

all_messages = app_tables.chat.search()
matches = {message['match'] for message in all_messages}
for match in matches:
  if min(match['complete']) == 1:
    for row in app_tables.chat.search(match=match):
      row.delete()

Out of curiosity… is all the above wrapped in a transaction?

Yes, all the callable server functions have decorators like this:

@anvil.server.callable
@anvil.tables.in_transaction

Grasping at straws here… is it possible that you’re accidentally “nesting” transactions? I’d expect it to produce a different message, though.

No, I don’t think so. I ran into that error in the past, so now I only use the transaction decorator on callable functions and only call the callable functions as server calls.

I tried removing the list comprehensions by instead using query operators. I’m not sure yet if that helped, but I just got the error again (anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: 74129824de) from somewhere in this:

assume_complete = datetime.timedelta(hours=4)
cutoff_m = sm.now() - assume_complete
# Note: 0 used for 'complete' field b/c False not allowed in SimpleObjects
old_matches = app_tables.matches.search(complete=[0],
                                        match_commence=q.less_than(cutoff_m),
                                       )
for row in old_matches:
  temp = row['complete']
  for i in range(len(temp)):
    # Note: 1 used for 'complete' field b/c True not allowed in SimpleObjects
    temp[i] = 1
  row['complete'] = temp

The errors continue (252543be21) despite my attempt to refactor:

for row in proposals_to_check:
  if len(app_tables.proposal_times.search(current=True, proposal=row))==0:
    row['current'] = False

you can try print statement before the if and after the if to see which row the error does occur. Apply the same for another row