Skip to content

[Question] interactive_sample.py hangs indefinitely if you close the browser without doing the login #808

@psimoes123

Description

@psimoes123

Describe the bug
I noticed that when you don't set up a timeout for the request and you close the browser without doing the login. The thread that gets created for the request doesn't terminate, which cause the application to hang indefinitely.

To Reproduce
Steps to reproduce the behavior:

  1. interactive_sample.py
  2. pretty much just follow the workflow there.

Expected behavior
I've used the msal library in other languages and the expected behavior is usually a thrown exception when the browser is closed.

What you see instead

a hanging thread that runs indefinitely. In the screenshot, I've paused the thread to see the stack trace.

Image

The MSAL Python version you are using
1.32.0

Additional context
In the file authcode.py AuthCodeReceiver._get_auth_response method. the method self._server.handler_request() is being called and is basically waiting a request, which I assume is waiting a response for the login browser. When the browser gets closed before the login, no message is sent to the _server, which basically is in a infinite loop waiting for a request (it doesn't have timeout). if you are using a terminal you need to ctrl+c to stop the running script and if you are using a gui like Tkinter or something, you basically need to force quit the application.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions