Skip to content

Commit 637a77f

Browse files
fix: send str using send_bytes in websocket for starlette server
.send_text called .send_bytes Bug introduced in #400, released since v1.25.0 This showed up when deploying in Modal with the error: ``` Traceback (most recent call last): File "/pkg/modal/_runtime/container_io_manager.py", line 764, in handle_input_exception yield File "/pkg/modal/_container_entrypoint.py", line 210, in run_input_async await generator_output_task # Wait to finish sending generator outputs. ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/pkg/synchronicity/async_wrap.py", line 29, in wrapper return await user_wrapper(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/pkg/synchronicity/async_wrap.py", line 29, in wrapper return await user_wrapper(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/pkg/synchronicity/async_wrap.py", line 32, in wrapper raise uc_exc.exc File "/pkg/modal/_runtime/container_io_manager.py", line 549, in generator_output_task messages_bytes = [serialize_data_format(message, data_format)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/pkg/modal/_serialization.py", line 346, in serialize_data_format return _serialize_asgi(obj).SerializeToString(deterministic=True) ^^^^^^^^^^^^^^^^^^^^ File "/pkg/modal/_serialization.py", line 217, in _serialize_asgi websocket_send=api_pb2.Asgi.WebsocketSend( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: expected bytes, str found ```
1 parent e625b0a commit 637a77f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

solara/server/starlette.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def send_text(self, data: str) -> None:
159159
if settings.main.experimental_performance:
160160
self.to_send.append(data)
161161
else:
162-
self.portal.call(self._send_bytes_exc, data) # type: ignore
162+
self.portal.call(self._send_text_exc, data) # type: ignore
163163

164164
def send_bytes(self, data: bytes) -> None:
165165
if self.portal is None:

0 commit comments

Comments
 (0)