SystemError: compiler stack_effect(opcode=0, arg=0) failed
at /home/anvil/downlink/anvil_downlink_worker/init.py:96
called from /home/anvil/downlink/anvil_downlink_worker/init.py:264
called from lib.effects.via_specifications, line 78
called from startup, line 119
What I’m trying to do: Normal app boot and server calls. My app is a Python-3 full-stack app; server modules are plain CPython.
The problem — it’s intermittent and not tied to specific code:
The same unchanged code boots cleanly in some sessions (reaches my “data ready” state, server calls succeed) and crashes at boot in others.
When it crashes, the crash location moves between sessions — sometimes one boot phase, sometimes a later one.
It hits previously-working, unchanged server functions too. A server callable that has worked reliably for weeks now throws the same stack_effect on some sessions, with no edits to it.
Every crashing session also shows a transport failure (reason=domain_error) on my first server calls, suggesting the runtime is unhealthy from the start of that session.
What I’ve already tried:
Reloading the app — sometimes a reload catches a clean worker and everything works; sometimes it doesn’t.
Deleting a recently-added server module entirely — no effect (the crash persisted and even moved to a different spec).
My questions:
What conditions cause stack_effect to fail inside anvil_downlink_worker? Is this a known worker-runtime issue rather than an app-code one?
Could frequent rapid redeploys (I deployed ~10 times in a short window while iterating) leave the server environment in a degraded state where module compilation fails?
Is there a way to force a full server-runtime restart (a fresh worker process), as opposed to a client reconnect, to recover from this?
I’m happy to share source if useful. Thanks in advance.
That…is an error I have never seen before! That’s an internal error in the Python interpreter. The line calling it corresponds to Anvil’s module loader, implying that whatever is causing the Python compiler(?) to puke is happening as we try to load one of your Modules or Server Modules.
It would be good to know:
What is the code in lib.effects.via_specifications line 78? Presumably it’s an import (although it’s a little surprising ); that will give us a hint what module it was trying to compile when it went wrong.
What is your code actually doing? You talk about “specifications” or the crash “moving to a different spec”, but I don’t know what those terms mean – could you give us a brief summary?
Are you using any libraries or utilites that might be doing code generation - either generating Python code or generating bytecode? Malformed bytecode is the sort of thing that might cause Python to throw a rod this unhelpfully.
What packages do you have installed? (You’re using Custom Packages, right? If you’re not, you’re using an old out-of-support version of Python anyway, so you should probably try upgrading)
In terms of forcing a restart, Anvil starts your server code in a separate Python process for each call, unless you have “Keep Server Running” enabled, in which case the Python process is reused between calls but we still create a new one each time you change any of your code (it’s keyed off the Git SHA).
Can you please expand on this a little bit? Do you see this same error message or is it different for you? When do you see it happen? Can you answer some of the problems I listed above?
I’m aware that deeply weird issues like this can be frustrating, and we’d love to help squash it, but I need somewhere to start digging!
I managed to catch it, its definetly pypdf.
It happens usually once a day, during one of the first runs of my app. I only use the online envirinment for graphical testing, but the actual app runs on an app-server with no problems, so generally its no biggie for me