Skip to content

WS connection close can cause render exception #21

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 17, 2021 · 5 comments
Closed
1 task done

WS connection close can cause render exception #21

Archmonger opened this issue Oct 17, 2021 · 5 comments

Comments

@Archmonger
Copy link
Contributor

Old Behavior

If the webpage is closed or refreshed prior to component load, an exception will occur.

2021-10-16T22:57:18-0700 | ERROR | Failed to render Button(2992041646976, websocket=WebsocketConnection(scope={'type': 'websocket', 'path': '/_idom/websocket/test_app.components.Button/', 'raw_path': b'/_idom/websocket/test_app.components.Button/', 'headers': [(b'host', b'127.0.0.1:8000'), (b'connection', b'Upgrade'), (b'pragma', b'no-cache'), (b'cache-control', b'no-cache'), (b'upgrade', b'websocket'), (b'origin', b'http://127.0.0.1:8000'), (b'sec-websocket-version', b'13'), (b'user-agent', b'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/94.0.4606.81 Safari/537.36'), (b'accept-encoding', b'gzip, deflate, br'), (b'accept-language', b'en'), (b'cookie', b'csrftoken=jzHH9Te6cml6zXxOwjSkdsMupUjoIPPLGkNGMvCsyUsdidzNmYJNBFWeflJI59Qe; sessionid=1t95jxh44o9a1zfzcgsamlhau1mxjilj'), (b'sec-gpc', b'1'), (b'sec-websocket-key', b'd5LydM5OiDLcAgSqam7GcQ=='), (b'sec-websocket-extensions', b'permessage-deflate; client_max_window_bits')], 'query_string': b'kwargs=%7B%7D', 'client': ['127.0.0.1', 52403], 'server': ['127.0.0.1', 8000], 'subprotocols': [], 'asgi': {'version': '3.0'}, 'cookies': {'csrftoken': 'jzHH9Te6cml6zXxOwjSkdsMupUjoIPPLGkNGMvCsyUsdidzNmYJNBFWeflJI59Qe', 'sessionid': '1t95jxh44o9a1zfzcgsamlhau1mxjilj'}, 'session': <django.utils.functional.LazyObject object at 0x000002B8A39433A0>, 'user': <channels.auth.UserLazyObject object at 0x000002B8A3943CA0>, 'path_remaining': '', 'url_route': {'args': (), 'kwargs': {'view_id': 'test_app.components.Button'}}}, close=<bound method AsyncWebsocketConsumer.close of <django_idom.websocket_consumer.IdomAsyncWebsocketConsumer object at 0x000002B8A3943E50>>, disconnect=<bound method IdomAsyncWebsocketConsumer.disconnect of <django_idom.websocket_consumer.IdomAsyncWebsocketConsumer object at 0x000002B8A3943E50>>, view_id='test_app.components.Button'))
Traceback (most recent call last):
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 207, in _render_component
    self._render_model(old_state, new_state, raw_model)
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 245, in _render_model
    self._render_model_children(old_state, new_state, raw_model.get("children", []))
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 364, in _render_model_children
    self._render_model(old_child_state, new_child_state, child)
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 244, in _render_model
    self._render_model_attributes(old_state, new_state, raw_model)
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 266, in _render_model_attributes
    self._render_model_event_handlers_without_old_state(
  File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 306, in _render_model_event_handlers_without_old_state
    self._event_handlers[target] = handler
AttributeError: _event_handlers

New Behavior

Need to gracefully handle WS close within _render_model

Implementation Details

No response

Code of Conduct

@Archmonger Archmonger linked a pull request Oct 28, 2021 that will close this issue
@Archmonger Archmonger added bug and removed triage labels Jan 12, 2022
@Archmonger Archmonger removed a link to a pull request Jan 12, 2022
@Archmonger Archmonger changed the title WS connection close can cause Render exception WS connection close can cause render exception Dec 30, 2022
@Archmonger
Copy link
Contributor Author

@rmorshea What do you think about moving this issue to core?

@rmorshea
Copy link
Contributor

That seems right to me.

@rmorshea
Copy link
Contributor

Do we know if this still happens though?

@Archmonger
Copy link
Contributor Author

I'll check.

@Archmonger
Copy link
Contributor Author

I wasn't able to replicate this with IDOM v0.43.0.

Closing issue.

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