clan-app: decode function arguments ahead of launching a thread.

If something goew wrong here we rather want to crash the app and get bug
reports.
This commit is contained in:
Jörg Thalheim
2025-05-14 11:51:45 +02:00
parent b491e9cd51
commit b09e61f68d

View File

@@ -68,12 +68,9 @@ class Webview:
arg: int,
) -> None:
op_key = op_key_bytes.decode()
def thread_task(stop_event: threading.Event) -> None:
try:
args = json.loads(request_data.decode())
log.debug(f"Calling {method_name}({args[0]})")
# Initialize dataclasses from the payload
reconciled_arguments = {}
for k, v in args[0].items():
@@ -91,6 +88,8 @@ class Webview:
# TODO: We could remove the wrapper in the MethodRegistry
# and just call the method directly
def thread_task(stop_event: threading.Event) -> None:
try:
set_should_cancel(lambda: stop_event.is_set())
result = wrap_method(**reconciled_arguments)