Anvil Internal Server Error in Production Environment

Hi, I have deployed my app that uses Uplink to generate PDFs. I am on the Individual tier of Anvil. My web app was working for a while, but now the PDF generation has stopped working. It’s hosted through AWS.

Here is what the logs say:

Traceback (most recent call last):
[Wed Mar 03 20:04:28.317557 2021] [:error] [pid 25454] [remote 72.182.118.213:32] File “/opt/python/run/venv/local/lib/python3.6/site-packages/anvil/server.py”, line 306, in call
[Wed Mar 03 20:04:28.317562 2021] [:error] [pid 25454] [remote 72.182.118.213:32] return _do_call(args, kwargs, fn_name=fn_name)
[Wed Mar 03 20:04:28.317568 2021] [:error] [pid 25454] [remote 72.182.118.213:32] File “/opt/python/run/venv/local/lib/python3.6/site-packages/anvil/server.py”, line 298, in _do_call
[Wed Mar 03 20:04:28.317572 2021] [:error] [pid 25454] [remote 72.182.118.213:32] return _threaded_server.do_call(args, kwargs, fn_name=fn_name, live_object=live_object)
[Wed Mar 03 20:04:28.317578 2021] [:error] [pid 25454] [remote 72.182.118.213:32] File “/opt/python/run/venv/local/lib/python3.6/site-packages/anvil/_threaded_server.py”, line 403, in do_call
[Wed Mar 03 20:04:28.317581 2021] [:error] [pid 25454] [remote 72.182.118.213:32] raise _server._deserialise_exception(r[“error”])
[Wed Mar 03 20:04:28.317595 2021] [:error] [pid 25454] [remote 72.182.118.213:32] anvil._server.AnvilWrappedError: AnvilWrappedError: ‘Internal server error: 68db3d6843e3’

Any suggestions? I’m not sure where to start - nothing changed in the code on our end.

Hi @brian.chiu112 ,

Sorry that’s misbehaving for you. A few questions:

  1. Does that happen every time you try to generate a PDF, or just sometimes?
  2. Does it happen with all your apps, or just one?
  3. If you try to generate a trivial PDF from a new, tiny app, do you see the same issue?

Let me know and I will do some more digging at this end!

Hey Ian,

  1. Every time
  2. This is actually an app that I developed myself (not through anvil), and I just use the instructions here to create a PDF. The function connects to Anvil via uplink, then uses render_form and write_to_file to generate the PDF. This function is called in a Flask endpoint.
  3. I tried it with just returning an empty PDF with the same simple Flask endpoint, and the same error occurs.

If it would help, I could send you more specific code in a private message, just let me know.

It started working again for a few hours yesterday. But it suddenly stopped working in use cases that were working just a few minutes before. Here are some sample logs:

2] Traceback (most recent call last):
[Fri Mar 05 04:39:17.129572 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 2464, in call
[Fri Mar 05 04:39:17.129576 2021] [:error] [pid 21514] [remote 146.112.43.80:132] return self.wsgi_app(environ, start_response)
[Fri Mar 05 04:39:17.129582 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 2450, in wsgi_app
[Fri Mar 05 04:39:17.129585 2021] [:error] [pid 21514] [remote 146.112.43.80:132] response = self.handle_exception(e)
[Fri Mar 05 04:39:17.129590 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 1867, in handle_exception
[Fri Mar 05 04:39:17.129593 2021] [:error] [pid 21514] [remote 146.112.43.80:132] reraise(exc_type, exc_value, tb)
[Fri Mar 05 04:39:17.129598 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/_compat.py”, line 39, in reraise
[Fri Mar 05 04:39:17.129601 2021] [:error] [pid 21514] [remote 146.112.43.80:132] raise value
[Fri Mar 05 04:39:17.129606 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 2447, in wsgi_app
[Fri Mar 05 04:39:17.129609 2021] [:error] [pid 21514] [remote 146.112.43.80:132] response = self.full_dispatch_request()
[Fri Mar 05 04:39:17.129614 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 1952, in full_dispatch_request
[Fri Mar 05 04:39:17.129618 2021] [:error] [pid 21514] [remote 146.112.43.80:132] rv = self.handle_user_exception(e)
[Fri Mar 05 04:39:17.129622 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 1821, in handle_user_exception
[Fri Mar 05 04:39:17.129626 2021] [:error] [pid 21514] [remote 146.112.43.80:132] reraise(exc_type, exc_value, tb)
[Fri Mar 05 04:39:17.129630 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/_compat.py”, line 39, in reraise
[Fri Mar 05 04:39:17.129633 2021] [:error] [pid 21514] [remote 146.112.43.80:132] raise value
[Fri Mar 05 04:39:17.129638 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 1950, in full_dispatch_request
[Fri Mar 05 04:39:17.129641 2021] [:error] [pid 21514] [remote 146.112.43.80:132] rv = self.dispatch_request()
[Fri Mar 05 04:39:17.129646 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py”, line 1936, in dispatch_request
[Fri Mar 05 04:39:17.129649 2021] [:error] [pid 21514] [remote 146.112.43.80:132] return self.view_functionsrule.endpoint
[Fri Mar 05 04:39:17.129654 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/current/app/app.py”, line 32, in generate_report
[Fri Mar 05 04:39:17.129658 2021] [:error] [pid 21514] [remote 146.112.43.80:132] output_file = anvil_generate_pdf(filePath, True)
[Fri Mar 05 04:39:17.129663 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/current/app/generate.py”, line 324, in anvil_generate_pdf
[Fri Mar 05 04:39:17.129666 2021] [:error] [pid 21514] [remote 146.112.43.80:132] realized_losses_values, mb_list)
[Fri Mar 05 04:39:17.129675 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/anvil/pdf.py”, line 4, in render_form
[Fri Mar 05 04:39:17.129678 2021] [:error] [pid 21514] [remote 146.112.43.80:132] return anvil.server.call(“anvil.private.pdf.component_to_pdf”, {}, args, kwargs)
[Fri Mar 05 04:39:17.129683 2021] [:error] [pid 21514] [remote 146.112.43.80:132] File “/opt/python/run/venv/local/lib/python3.6/site-packages/anvil/server.py”, line 309, in call
[Fri Mar 05 04:39:17.129687 2021] [:error] [pid 21514] [remote 146.112.43.80:132] raise _server._deserialise_exception(e.error_obj)
[Fri Mar 05 04:39:17.129697 2021] [:error] [pid 21514] [remote 146.112.43.80:132] anvil._server.AnvilWrappedError: AnvilWrappedError: ‘Internal server error: d3be4b96414b’

Thanks for the update! When you’re attempting to generate a PDF, does that Exception come back quickly, or after some time? And when it works, how long does it take to generate the PDF?

It takes some time - but that has to do with the run time of the processes I’m using to format the data, not on your side of things.

Understood. How long is “some time”? There are strict timeouts during PDF rendering, and the generation will fail if it takes too long for the UI to display. That said, you should get a more helpful error message than this!

The PDF rendering itself doesn’t take long. It shouldn’t be timing out - I don’t believe that is the issue. Depending on the .csv file I’m processing, it takes between 1 - 15 seconds for the error to occur. But like I said, that is just data formatting with pandas and such that has nothing to do with Anvil. Running the code locally as a python script like instructed works and the PDF is rendered every time without fail.

Hi there,

I’m afraid we still haven’t been able to reproduce this at all. I’d like to help you get to the bottom of it, though. Please can you:

  • Create a new, blank Anvil app
  • Create a new, blank Uplink script
  • Add the minimum code required to both to demonstrate the error, then post the contents of your Uplink script and a Clone Link for the app to this thread, along with instructions to cause the error.

Then, once we can reproduce the problem, we should be able to work out what’s going on. Thanks!