Form failed to load in designer with a SessionExpiredError

What I’m trying to do:

Navigate to design view of a template in the web editor

What I’ve tried and what’s not working:

On a page I have inserted a custom component that makes a server call in the custom component’s form_show. It seems that the call to that server function is throwing an error in the designer only (running in debug works fine).

Bug:

Designer output:
anvil.server.SessionExpiredError: Session expired
<running on the server>

Error in place of the design view:

Can you share some of the relevant client and server code? it’s pretty hard to debug without any code.

The culprit client code in the custom component is here:

def form_show(self, **event_args):
    """This method is called when the form is shown on the page"""
    with anvil.server.no_loading_indicator:
      self.data_table = anvil.server.call('get_data_view')

the designer loads fine when commenting that particular server call. It’s not the only server call I have in show methods but is the only one causing the issue.

The relevant server code is:

@anvil.server.callable
def get_data_view():
    user = anvil.users.get_user()
    return app_tables.tdata.client_readable(
        q.only_cols("dt", "category"),
        user=user, processed=True, dt=q.not_(None)
    )

I should also mention, the designer view of the custom component itself loads fine. The error only appears when inserting the component in another page. The page in which the component is inserted has no client code beyond instantiation.

You typically don’t want that code to run in the IDE, at Design time. For a way to prevent that code from running, at this wrong time, see the “as-yet-undocumented but useful feature” here:

That did it, thank you!

2 Likes