-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
node:dgram compatibility improvements #16446
Conversation
if (nread < 0) { | ||
return self.emit( | ||
"error", | ||
Object.assign(new Error("recvmsg"), { |
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.
This seems not great but I don't want to block merging on it
throw new ErrnoException(err, 'setBroadcast'); | ||
const handle = this[kStateSymbol].handle; | ||
if (!handle?.socket) { | ||
throw new Error("setBroadcast EBADF"); |
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.
We should be using a using errors with codes instead of errors with messages. It sounds like we need a helper for throwing a system error with a syscall name and an errno.
*/ | ||
const handle = this[kStateSymbol].handle; | ||
if (!handle?.socket) { | ||
throw new Error("setMulticastTTL EBADF"); |
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.
Here as well
*/ | ||
const handle = this[kStateSymbol].handle; | ||
if (!handle?.socket) { | ||
throw new Error("setTTL EBADF"); |
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.
And here
byteLength += length; | ||
byteLength += length; | ||
} else { | ||
throwTypeError(lexicalGlobalObject, throwScope, "Buffer.concat expects Buffer or Uint8Array"_s); |
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.
This throwTypeError -- is that throwing the error with the code property that is expected or is it not doing that?
What does this PR do?
Improves the dgram module to add features and fix bugs. Adds some tests from Node.js.
How did you verify your code works?
Added tests.