Skip to content

util: implement util.getSystemErrorName()

Reimplement uv.errname() as internal/util.getErrorName() to avoid the memory leaks caused by unknown error codes and avoid calling into C++ for the error names. Also expose it as a public API for external use.

The next step would be to deprecate uv.errname() (since the binding seems to be used in the user land, e.g. execa), remove the C++ code and monkey patch the binding to internal/util.getErrorName() during bootstrapping, although I am not sure when during the bootstrapping process is the best time to do that.

Refs: http://docs.libuv.org/en/v1.x/errors.html#c.uv_err_name

const char* uv_err_name(int err) Returns the error name for the given error code. Leaks a few bytes of memory when you call it with an unknown error code

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

util, child_process, test

Merge request reports

Loading