Skip to content
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 crashing with large updates #217

Open
CraigFeldspar opened this issue Apr 11, 2024 · 6 comments
Open

Websocket crashing with large updates #217

CraigFeldspar opened this issue Apr 11, 2024 · 6 comments

Comments

@CraigFeldspar
Copy link

CraigFeldspar commented Apr 11, 2024

Whenever using the test y-sweet endpoint, I often get the websocket to crash :

main.mjs:533 WebSocket connection to 'wss://y-sweet.net/p/....(url hidden)' failed: Close received after close

After that, no reconnection happens automatically, the page needs to be reloaded.
This happens usually with larger updates rather that short ones. Is there some message size limitation ? If yes, how can we gracefully handle these kind of errors in order to resend the updates more gradually ?

Also, if you need the full URL to analyze logs on your side, please let me know

@paulgb
Copy link
Member

paulgb commented Apr 11, 2024

Thanks for reporting, Craig.

When you say large updates, do you have a ballpark estimate of how large these updates are? (I can start by generating updates of that size to see if I can replicate it)

@CraigFeldspar
Copy link
Author

CraigFeldspar commented Apr 12, 2024

So I got it to crash with roughly 10k keys updates, each key is a 36-lengthed string, and each value is a record holding 2 keys and 6 numbers as values.
I would say this sums up to roughly 150 bytes per key-value pair, times 10k, so 1.5 Mb (before yjs-ysweet internal binary compression)

@CraigFeldspar
Copy link
Author

@paulgb I managed to get a simple repro for you :

https://github.com/CraigFeldspar/ysweet-crash

Steps :

  • Clone repo
  • Go to examples/nextjs, follow readme there (this is a clone of this repo)
  • Navigate to http://localhost:3000/color-grid
  • Websocket crashes after a few seconds : main.mjs:533 WebSocket connection to 'wss://y-sweet.net/p/ubMbiDgDY1Nh02b0vdE/doc/ws/94sJrtvfZSSzpqAu9FusX?token=...' failed: Close received after close

I just added to the base color grid example this piece of code in ColorGrid.tsx:

  const sceneMap = useMap<any>('sceneMap')

  useEffect(() => {
    ;(async () => {
      const obj = await (await fetch('./data.json')).json()
      for (const key in obj) {
        sceneMap.set(key, obj[key])
      }
    })()
  }, []) 

data.json is ~7Mb in size

@paulgb
Copy link
Member

paulgb commented Jul 9, 2024

Thank you! Will take a look.

@ilya2204
Copy link

Any updates? I have this issues too

@jh-plask
Copy link

This is related to the websocket message size limit(1MiB) of Cloudflare durable object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants