-
Notifications
You must be signed in to change notification settings - Fork 7
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
protocol: frame messages with length-prefix instead of newlines #51
Conversation
const spy = vi.fn(); | ||
parser.on('data', spy); | ||
|
||
const emojiMessage = '🇧🇪🇨🇦👨👩👧👦'; |
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.
giuseppe would be proud.
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 notorious 🇩🇪 returns
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.
❤️
}); | ||
} | ||
|
||
export const MessageFramer = { |
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.
is it worth having a no-op framer for when we write these things to a websocket transport (or something that already has framing built-in? like a SEQPACKET UDS)
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.
ah nevermind, i saw that those cases don't even use one. carry on.
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
Why
We want to have newlines in our messages :) The old approach failed when we used the binary codec with a string or Uint8Array that contained a newline in it. This is because we framed our messages with newlines so we would get cases where a single message would be split in two.
What changed
Use
uint32
-prefix framing instead.