Form failed to load in designer with a SessionExpiredError

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: