-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add better support for binary data on WebSocket connections #5897
Add better support for binary data on WebSocket connections #5897
Conversation
1cfc1db
to
15e8ba8
Compare
if ('data' in event && typeof event.data === 'object') { | ||
return 'Binary data'; | ||
} | ||
return event.data.toString('utf-8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utf8 is the default toString of a buffer so we shouldn't need to specify this
raw = Buffer.from(event.data.data).toString('utf-8'); | ||
} | ||
} catch (err) { | ||
// Ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the stringify should go in the catch next to the intent, and its safe to do it no matter what type it is.
if ('data' in event && typeof event.data === 'object' && 'data' in event.data && Array.isArray(event.data.data)) { | ||
raw = Buffer.from(event.data.data).toString('utf-8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event.data should be an arraybuffer rather than an object containsing a array named data if im not mistaken websockets/ws#1222
Closes INS-2574
Closes #5864
changelog(Improvements): Add better support for binary data on WebSocket connections