Skip to content

Websocket Consumer can get stuck in infinite connection loop #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Archmonger opened this issue Oct 26, 2021 · 8 comments
Closed
1 task done

Websocket Consumer can get stuck in infinite connection loop #22

Archmonger opened this issue Oct 26, 2021 · 8 comments

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Oct 26, 2021

Old Behavior

WebSocket HANDSHAKING /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61944]
WebSocket CONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61944]
WebSocket DISCONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61944]
WebSocket HANDSHAKING /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61945]
WebSocket CONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61945]
WebSocket DISCONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61945]
WebSocket HANDSHAKING /_idom/websocket/test_app.components.SimpleBarChart/ [127.0.0.1:61953]
WebSocket CONNECT /_idom/websocket/test_app.components.SimpleBarChart/ [127.0.0.1:61953]
WebSocket DISCONNECT /_idom/websocket/test_app.components.SimpleBarChart/ [127.0.0.1:61953]
WebSocket HANDSHAKING /_idom/websocket/test_app.components.Button/ [127.0.0.1:61955]
WebSocket CONNECT /_idom/websocket/test_app.components.Button/ [127.0.0.1:61955]
WebSocket DISCONNECT /_idom/websocket/test_app.components.Button/ [127.0.0.1:61955]
WebSocket HANDSHAKING /_idom/websocket/test_app.components.HelloWorld/ [127.0.0.1:61956]
WebSocket CONNECT /_idom/websocket/test_app.components.HelloWorld/ [127.0.0.1:61956]
WebSocket DISCONNECT /_idom/websocket/test_app.components.HelloWorld/ [127.0.0.1:61956]
WebSocket HANDSHAKING /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61957]
WebSocket CONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61957]
WebSocket DISCONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61957]
HTTP GET /_idom/web_module/from-template/victory-bar.js 200 [0.01, 127.0.0.1:64500]

I'm really not sure how to trigger this. Seems to happen sometimes while using the development webserver with autoreload (settings.py:DEBUG=True)

When this occurs, the websocket will be stuck in a perpetual handshake/connect loop for a minute or two. Happens the same within Conreq, and I'm not using any external web modules over there yet.

Somehow, using a keyboard interrupt (CTRL+C) to attempt to escape the situation does not resolve the bug. Will still be stuck in this infinite connection loop upon restarting the development webserver (manage.py runserver)

New Behavior

WS connection and render should be performed smoothly

Implementation Details

Need to debug

Code of Conduct

@Archmonger
Copy link
Contributor Author

Archmonger commented Oct 27, 2021

Yeah this is actually a massive issue, it keeps occurring during typical development workflows which keeps halting development until it resolves itself.

Performing development off the #17 branch, since the main branch still doesn't have a pinned django-idom-client version.

@Archmonger
Copy link
Contributor Author

Archmonger commented Oct 28, 2021

Seems like rapidly refreshing the page generated by manage.py runserver is enough to induce this issue to occur.

Perhaps it's related to refreshing the page in the middle of the element's first render.

@Archmonger
Copy link
Contributor Author

Archmonger commented Oct 28, 2021

@rmorshea This issue definitely falls under P1/Critical.

Confirmed this also occurs in non-development environments. Since an exception isn't being generated by this, I can't trace down the exact problematic LOC.

This fully breaks IDOM for web usage, since IDOM completely halts whenever a webpage is refreshed too quickly.

My best guess is this is some bug related to dispatch_single_view (see previous comment), which means it digs into IDOM Core.

I've confirmed I can also completely break IDOM on our server used for IDOM docs examples.

@rmorshea
Copy link
Contributor

Dang... that's a bad one. My best guess is that the server gets held up trying to create and then immediately stop the dispatch loop each time the user refreshes the page? At least the page eventually recovers. It just takes a long time.

@Archmonger
Copy link
Contributor Author

Recovery takes 1-2 minutes, but I'm not sure exactly what is timing out.

@rmorshea
Copy link
Contributor

rmorshea commented Oct 28, 2021

Can you report this problem in an idom-team/idom discussion? We might need to organize a debug session. I have a feeling this is going to be rather nasty to tease out.

@Archmonger
Copy link
Contributor Author

Discussion created
reactive-python/reactpy#524

@Archmonger
Copy link
Contributor Author

Can no longer reproduce on Chromium/Brave builds. Seems to have been patched.

Closing this issue ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants