-
Notifications
You must be signed in to change notification settings - Fork 301
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
WebSocket Serialization Error in Durable Objects RPC #2319
Comments
I believe we do plan on supporting serializing WebSockets, but in the meantime you'll need to use |
I'm very pleased that serialization for WebSocket might be supported in the future, as it means we won't have to rely on fetch anymore. It would be great if this feature were implemented.
I understand that we should continue using fetch as usual. I also thought this was the only method. Thank you for your response. |
I understand that, for now, as a workaround, we should use fetch. I am satisfied with this solution, so it's fine to close this issue. However, I think it might be helpful to keep this issue open for anyone who encounters this problem in the future. What do you think about keeping it open until WebSocket serialization is implemented? |
@naporin0624 that sounds reasonable, and thank you for the report. |
Marking this as a feature request /cc @kentonv |
One way that you may be able to workaround this is to wrap the websocket with a ReadableStream and WritableStream pair, which can be shared over the jsrpc connection. |
Yeah this is an unfinished TODO for RPC. I'm not sure exactly when I'll get to it, probably some time in the next few months. Using |
a feature like this will be really helpful 👍 |
When attempting to use
DurableObjects RPC
with a WebSocket, an error is encountered during serialization. The error message indicates that objects of typeWebSocket
cannot be serialized. This issue is blocking the use of WebSockets in Durable Objects, which is critical for real-time applications.Error Message
Reproduction Steps
DurableObjects
.Sample Code
Here is a simplified version of the code that reproduces the issue:
Expected Behavior
WebSocket objects should be serializable, or there should be a documented alternative method for handling WebSockets within Durable Objects RPC.
Actual Behavior
Serialization fails with a
DataCloneError
, making it impossible to use WebSockets within Durable Objects RPC.Additional Information
3.61.0
Relevant Code Reference
The issue seems to be related to the following code in
workerd
:workerd/src/workerd/jsg/ser.c++
Lines 54 to 63 in bd09e5b
Suggested Fix
Please provide support for WebSocket serialization or offer a workaround for handling WebSockets in Durable Objects.
Thank you for your attention to this issue.
The text was updated successfully, but these errors were encountered: