TimeoutError: Server code took too long

Hello,

I’m working with a local database and using Anvil locally. I’m using an individual Anvil plan.

The issue is that when my table contains more than 10-15 rows of data and I’m trying to display them, I always have error “TimeoutError: Server code took too long” after 30 seconds. I saw that these limitations only happen with the free plan of Anvil, which isn’t the case here.

I read on Anvil that it could also be a variable name conflict in the server module.
However, in that case,​ the error should always raise while I can see it only when we have many rows of data.

Did anyone ever encounter this issue?

Have a great day!

Some more detail might help the readers understand your situation. Specifically:

Via Uplink? Or have you installed an entire installation of Anvil, running the entire thing locally?

1 Like

Hi!

Thanks for your fast reply and for your suggestion!

Yes, we use Anvil locally via Uplink.
Have you ever encountered this problem?

Best

Yes, we have. Calls to Uplink functions time out just as calls to Server functions do.

This was expected. Some of our function calls are quite compute-intensive.

Before Anvil created Background Tasks, our solution was to build an Uplink-side “pipeline”:

  1. A server-side function that created a database table row, to log an outgoing request, and provide a place to put the result.
  2. An Uplinked Listener, that accepted calculation requests, queued them for execution, and returned as quickly as possible, thus avoiding the timeout.
  3. A (local) processing engine, that ran through its input queue, and delivered results to an output queue.
  4. An Uplinked Shipper, that delivered items from the output queue to the intended database row.

With suitable bookkeeping, #2 can be expanded to many engines, running in parallel. This would reduce lag time on concurrent requests.