diff --git a/openslides/users/views.py b/openslides/users/views.py index f52d218a5..72a102e83 100644 --- a/openslides/users/views.py +++ b/openslides/users/views.py @@ -647,7 +647,9 @@ class PasswordResetView(APIView): "protocol": "https" if self.use_https else "http", "domain": current_site.domain, "path": "/login/reset-password-confirm/", - "user_id": urlsafe_base64_encode(force_bytes(user.pk)).decode(), + "user_id": urlsafe_base64_encode( + force_bytes(user.pk) + ), # urlsafe_base64_encode decodes to ascii "token": default_token_generator.make_token(user), "username": user.get_username(), } diff --git a/openslides/utils/websocket.py b/openslides/utils/websocket.py index a2585c77e..032fb342c 100644 --- a/openslides/utils/websocket.py +++ b/openslides/utils/websocket.py @@ -25,8 +25,8 @@ class ProtocollAsyncJsonWebsocketConsumer(AsyncJsonWebsocketConsumer): ) -> None: """ Sends the data with the type. - If silence_errors is True (default), all ConnectionClosed errors - during sending will be ignored. + If silence_errors is True (default), all ConnectionClosed + and runtime errors during sending will be ignored. """ out = {"type": type, "content": content} if id: @@ -35,7 +35,12 @@ class ProtocollAsyncJsonWebsocketConsumer(AsyncJsonWebsocketConsumer): out["in_response"] = in_response try: await super().send_json(out) - except ConnectionClosed as e: + except (ConnectionClosed, RuntimeError) as e: + # The ConnectionClosed error is thrown by the websocket lib: websocket/protocol.py in ensure_open + # `websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1005 + # (no status code [internal]), no reason` (Also with other codes) + # The RuntimeError is thrown by uvicorn: uvicorn/protocols/websockets/websockets_impl.py in asgi_send + # `RuntimeError: Unexpected ASGI message 'websocket.send', after sending 'websocket.close'` if not silence_errors: raise e