@change Listeners Bypass Uncaught Exception Life Cycle

オープン
#103 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Start with the exception example at examples/exceptions/app_trame.py and reproduce the issue by adding the shown @change listener that raises an error. The issue says this began in trame-server==3.13.2 after #95; inspect that change and trace how listener exceptions reach the life cycle handler. Done when the exception life cycle event fires for errors raised by a @change listener.

索引モデルが issue の本文から書いたものです。

説明

If you take the exception example and add a @change listener with an error in the code, the life cycle event will be bypassed.

This did not start occurring until trame-server==3.13.2 after #95.

Modified app_trame.py Example

Click to expand
import logging
import sys
import traceback

from trame.app import TrameApp
from trame.ui.html import DivLayout
from trame.widgets import html

from trame.decorators import change, life_cycle

# Disable default stdout exception
logging.getLogger("wslink.protocol").setLevel(logging.CRITICAL)


class MonitorException(TrameApp):
    def __init__(self, server=None):
        super().__init__(server)
        self.server.state.test = 1
        self._build_ui()
        # self.ctrl.on_exception.add(self.on_exception)

    def _build_ui(self):
        with DivLayout(self.server) as self.ui:
            html.Button("Divide by 0", click=self.divide_by_zero)
            html.Button("JS error", click="console.error('Yo')")
            html.Button("Divide by 0 in change listener", click="test += 1")

    def divide_by_zero(self):
        return 1 / 0

    @life_cycle.exception
    def on_exception(self, exception):
        print(">" * 60)
        print("exception ->", exception)
        traceback.print_exception(
            type(exception), exception, exception.__traceback__, file=sys.stdout
        )
        print("<" * 60)

    @life_cycle.error
    def on_js_error(self, msg):
        if msg == "[object Object]":
            # exception... => should fix JS to send a better msg/event
            return

        print("JS error:", msg)

    @change("test")
    def test_is_changed(self, **_):
        return 1 / 0


def main():
    app = MonitorException()
    app.server.start()


if __name__ == "__main__":
    main()

主要言語
Python
スター
17
フォーク
16
平均マージ
1日 15時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Kitware/trame-server のほかの issue

Kitware/trame-server の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。