Skip to content
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

fix rendering issue #442

Merged
merged 2 commits into from
Jul 17, 2023
Merged

fix rendering issue #442

merged 2 commits into from
Jul 17, 2023

Commits on Jul 13, 2023

  1. logging: remove obsolete information when logging ClientError exceptions

    Previously, a raised `lona.errors.ClientError` was logged two times. Once by
    the view runtime, that received the error, and a second time by the general
    logging setup of Lona. The first log entry contained the JavaScript traceback,
    raised by the browser, the second log entry contained the full Python traceback
    from the server side.
    
        LonaWorker_0                   ERROR    12:39:31.344648 lona.view_runtime client error raised:
        node with id 39 is already cached
    
        LonaRuntimeWorker_0            ERROR    12:39:31.345355 lona.view_runtime Exception raised while running </home/fscherf/devel/lona/test_project/views/view_types/interactive_view.py.InteractiveView object at 0x7f979c06cc10>
          Traceback (most recent call last):
            File "/home/fscherf/devel/lona/lona/view_runtime.py", line 348, in start
              return_value=self.view.handle_request(self.request),
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/home/fscherf/devel/lona/test_project/views/view_types/interactive_view.py", line 56, in handle_request
              self.sleep(float(interval.value))
            File "/home/fscherf/devel/lona/lona/view.py", line 344, in sleep
              return self._await_sync(asyncio.sleep(delay, result))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/home/fscherf/devel/lona/lona/view.py", line 109, in _await_sync
              ).result()
                ^^^^^^^^
            File "/home/fscherf/.pyenv/versions/3.11.4/lib/python3.11/concurrent/futures/_base.py", line 456, in result
              return self.__get_result()
                     ^^^^^^^^^^^^^^^^^^^
            File "/home/fscherf/.pyenv/versions/3.11.4/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
              raise self._exception
            File "/home/fscherf/devel/lona/lona/view.py", line 104, in await_awaitable
              raise cast(StopReason, self._view_runtime.stop_reason)
    
    The second log entry does not contain any meaningful information, and
    the Python traceback only contains Lona framework code, never application code.
    Thus it only made these errors harder to read.
    
    This patch adds a new rule to `lona.logging.LogFilter` to filter out log
    entries containing a `lona.errors.ClientError` traceback.
    
    Signed-off-by: Florian Scherf <mail@florianscherf.de>
    fscherf committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    919a618 View commit details
    Browse the repository at this point in the history
  2. client2: rendering: fix crash when moving a node

    Previously, client2 crashed when an already rendered node was moved by
    appending or inserting it twice within the same HTML tree.
    
        moving_node = Div('node 3')
    
        html = HTML(
            Div(
                'node 1',
                moving_node,
            ),
            Div('node 2'),
        )
    
        self.show(html)
    
        html[1].append(moving_node)
    
        self.show(html)  # resulted in: ERROR  lona.view_runtime  client error raised: node with id 952 is already cached
    
    When a node is moved by adding it twice to the same node tree, internally, it
    gets destroyed at the old location, and a new node, with the old id, gets
    rendered in the new location.
    
    Previously, the rendering engines node cache got not cleaned after the first
    step, so all child nodes of `moving_node`, which is a text node with the text
    "node 3" in this case, remained cached.
    When the rendering engine attempted to render a new div, identical to the
    former removed one, the cache function would raise an error because the old
    text node still was cached.
    
    This patch adds a cache cleaning call to the rendering engines `_remove_node`
    method and adds a rendering test for moving nodes.
    
    Signed-off-by: Florian Scherf <mail@florianscherf.de>
    fscherf committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    3cd59e6 View commit details
    Browse the repository at this point in the history