-
One of the problems that I ran into with the old uWebSockets.js version (the long gone one) was that the data returned by onMessage events would be unsafe to keep around for even very short time frames. Eventually the contents would change, so I had to make sure to copy the buffer immediately upon retrieval. Is this still the case now? I can see that you are copying data immediately upon retreiving it in one of the examples, but I cant make out whether you're just trying to convert the array type or if this is how you are supposed to use the onMessage events in general. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
WebSocket messages, Http headers, urls, methods, and everything that is not the socket itself dies with return, so if you don't handle it before returning or yielding by await you will need to copy it somewhere. You only need to copy what you actually need, so if you need the url - copy only the url. Same goes with one particular header value, etc. |
Beta Was this translation helpful? Give feedback.
WebSocket messages, Http headers, urls, methods, and everything that is not the socket itself dies with return, so if you don't handle it before returning or yielding by await you will need to copy it somewhere.
You only need to copy what you actually need, so if you need the url - copy only the url. Same goes with one particular header value, etc.