Repository navigation
Implement util._errnoException and util._exceptionWithHostPort - #8848
littledivy wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Superseded by the review of
2de8a258.
This review, of 2384bcdf
✅ Approved — No issues found. Both functions match Node's behavior, reuse the existing validation and errno-name helpers, and come with tests.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No issues found. err is validated before use. syscall, address and additional only end up in the error message and properties. The change adds no new entry points or privileges.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
No issues found. The shared errnoError helper builds the message and the errno/code/syscall properties in the same order Node does, and each exported function adds its own fields and stack capture.
⚡ Performance: ✅ LGTM
No issues found.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: 2384bcdf
`util._errnoException()` and `util._exceptionWithHostPort()` threw ERR_METHOD_NOT_IMPLEMENTED. Node exposes both, and libraries that build Node-style errors for failed syscalls call them. In this patch both build the same errors as Node 26's ErrnoException and ExceptionWithHostPort: a plain Error whose message is the syscall, the libuv error name and the details, with own `errno`, `code` and `syscall` properties (and `address`, plus `port` when it is non-zero), in Node's order. The name comes from the libuv table that `getSystemErrorName()` already uses, so the numbers are Linux's, as Node reports them on Linux. `err` is validated the same way, so a non-number throws ERR_INVALID_ARG_TYPE and anything but a negative integer throws ERR_OUT_OF_RANGE. The stack starts at the caller. Node's permission-model branch is left out, since workerd has no permission model. No compat flag: both functions threw for every input, so the only change is that calls which threw ERR_METHOD_NOT_IMPLEMENTED now return an Error, or throw ERR_INVALID_ARG_TYPE / ERR_OUT_OF_RANGE for an invalid `err`. The new tests fail without the change.
2384bcd to
2de8a25
Compare
There was a problem hiding this comment.
✅ Approved — No issues found. Both functions produce the same errors as Node, reuse the existing err validation and errno-name lookup, and the updated tests cover the edge cases.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
err is validated before it is used. syscall, address and additional end up only in the error's message and properties. The change adds no entry points and grants no new privileges.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The shared errnoError helper sets the message and the errno, code and syscall properties in Node's order. validateSystemError narrows err to a number. The address and port handling, the original and additional formatting, and the Error.captureStackTrace calls all match Node. The updated tests cover property order, errno numbering, a negative port, an omitted port and invalid err values.
⚡ Performance: ✅ LGTM
Each function runs one validation, one error-name lookup and one stack capture per call. Neither is on a hot path.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: 2de8a258
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8848 +/- ##
==========================================
- Coverage 67.73% 67.71% -0.03%
==========================================
Files 848 848
Lines 215725 215801 +76
Branches 32511 32511
==========================================
Hits 146121 146121
- Misses 50404 50480 +76
Partials 19200 19200 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
util._errnoException()andutil._exceptionWithHostPort()threw ERR_METHOD_NOT_IMPLEMENTED. Node exposes both, and libraries that build Node-style errors for failed syscalls call them.In this patch both build the same errors as Node 26's ErrnoException and ExceptionWithHostPort: a plain Error whose message is the syscall, the libuv error name and the details, with own
errno,codeandsyscallproperties (andaddress, plusportwhen it is non-zero), in Node's order. The name comes from the libuv table thatgetSystemErrorName()already uses, so the numbers are Linux's, as Node reports them on Linux.erris validated the same way, so a non-number throws ERR_INVALID_ARG_TYPE and anything but a negative integer throws ERR_OUT_OF_RANGE. The stack starts at the caller. Node's permission-model branch is left out, since workerd has no permission model.No compat flag: both functions threw for every input, so the only change is that calls which threw ERR_METHOD_NOT_IMPLEMENTED now return an Error, or throw ERR_INVALID_ARG_TYPE / ERR_OUT_OF_RANGE for an invalid
err. The new tests fail without the change.