Conversation
Extract the UDP send implementation into a shared internal helper and use it from both Client and Server. Add Server#send(message, port, host, callback?) so a bound server socket can send replies from the same port without monkey-patching Client methods. Cover the new behavior with round-trip, in-handler reply, pre-listening error, and closed-socket promise rejection tests, and extend the TypeScript fixtures to exercise the new API. Closes: #190
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39ee7a31d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cb(error); | ||
| return; | ||
| } | ||
|
|
||
| throw error; |
There was a problem hiding this comment.
Reject pre-listening sends instead of throwing synchronously
In the no-callback form, send() is documented/used as a Promise API, but this branch throws before any Promise is created. That means server.send(...).catch(...) right after construction cannot catch the failure and instead gets a synchronous exception, which is inconsistent with the rest of the Promise-based methods in this module. For no-callback calls, this should return a rejected Promise so callers can reliably handle startup races.
Useful? React with 👍 / 👎.
Extract the UDP send implementation into a shared internal helper and use it from both Client and Server.
Add Server#send(message, port, host, callback?) so a bound server socket can send replies from the same port without monkey-patching Client methods.
Cover the new behavior with round-trip, in-handler reply, pre-listening error, and closed-socket promise rejection tests, and extend the TypeScript fixtures to exercise the new API.
Closes: #190