Error when signing in with anvil.users.login_with_form() - Internal error

What I’m trying to do:
Hey everyone. I have a simple login form where users need to fill in their email and password and if the user exists and is enabled, they should be able to proceed.

My functions and forms work correctly, but there is still an annoying [An internal error has occurred] notification that pops up in the output console. Everything seems to work. Only valid users can sign in and if the user doesnt exist, it doesn’t allow them to proceed. But what can I do to get rid of the pesky error?

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

Code Sample:

class LoginForm(LoginFormTemplate):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)
        
  def login_btn_click(self, **event_args):
    """This method is called when the button is clicked"""
    
    user = anvil.users.get_user()
    print(f'User: {user}') # Should print 'None' if no one is signed in
    anvil.users.login_with_form()
    print('Form has been filled in.')
    user = anvil.users.get_user()
    print(f'User: {user}') # Should print 'None' if no one is signed in
    Notification('Successfully signed in.').show()
    open_form('NavBarForm')

The output from the above for a successful login is as follows:

OUTPUT CONSOLE:
User: None
[An internal error has occurred]
Form has been filled in.
User: <LiveObject: anvil.tables.Row>

So as you can see, I manage to sign in successfully and everything else works, but the error remains.
This only occurs when I sign in with email and password (ie no existing user signed in already). If I don’t logout from a previous session and I click on the Login button, then no error arises.

Thanks for reporting @nico

I’ve moved to bug reports
I tried your code and I’m not seeing anything odd

Things you could try and report back to us:

  • are you using mac/windows?
  • does it happen in all browsers? which ones?
  • what about a private tab?
  • what about when you run the app in a new tab from the IDE?
  • does it only happen in the IDE - have you tried a published link?

To see more details about this error:

  • open the app in a new tab
  • open up the browser developer tools console
  • optional - type clear() to remove the existing messages
  • click the login button and see if any errors get reported in the javascript console

let me know if any of the above doesn’t make sense

Hi @stucork,

  • I’m using windows
  • I’ve tried both Chrome and Microsoft Edge, it happens in both.
  • When you say private tab, do you mean an incognito window? If so, yes it still happens then.
  • Problem persists even in a new tab.
  • Problem persists in a published link as well.

I can still use the app without any issues, but I do think it good practice to eliminate the error even if it isn’t affecting app performance.

Regarding the console, this is what I’m seeing:

Thanks for your help

thanks for that - when you run it with a published link - what does the error message say in anvil’s red error reporting component, the one in the bottom right corner?

Is this the component you’re talking about?

image

no i mean this one:

It’ll only happen when you run the published app

The errors in the console you showed, aren’t anything out of the ordinary, and they are unlikely to be the cause.

You may also find more details about the error in your logs
If you go to app logs and look for sessions like

So the app log doesn’t help much:

I did run the published app, but no such red error box popped up. Or at least none that I can see.

We’re narrowing it down - no red anvil indicator means that it’s only an error in the IDE.

If you try running the app in the IDE but in a new tab:
Screenshot 2022-03-25 at 10.42.56

And repeat the steps in the browser dev tools console
You might be able to see the error, but Unknown error probably means what you do see won’t be that helpful either.

It could be a number of things

  • Are you using JavaScript in Native Libraries?
  • Do you have many browser extensions?

You can also share a clone link to this thread and I can take a look
Or, if there is sensitive information you can share a clone link with me as a private message
(and steps to reproduce)

Just thought I would provide an update on this error. It seems like it only happens in the classic editor. With the beta editor, I haven’t come across it again.

1 Like