libuv: error codes on windows

  • Version: ? (The one in node.js 10.11.0)
  • Platform: Windows 10

I’m using libuv through node.js so sorry for not knowing the exact version.

One of my pet peeves with node.js/libuv is how many errors on windows are mapped to “UNKNOWN” with all details about the error being lost completely, which makes debugging user reports a nightmare.

Concrete example: require('child_process').spawn(<something that isn't actually an executable, like a text file>) calls uv_spawn under the hood (not sure about the parameters, sry) which in turn calls CreateProcessW. The error produced by windows is code 193 - “%1 is not a valid Win32 application” - which is a fairly useful error message. uv_spawn seems to return UNKNOWN - “unknown error” which isn’t.

Or: accessing any file on disk can trigger 1224 - “The requested operation cannot be performed on a file with a user-mapped section open.” due to virus scanners locking files. It should probably map to EBUSY so user code can retry the call but instead it maps, again, to UNKNOWN.

Mapping the above cases to something more reasonable is probably easy enough, but they are only examples that we found more by accident than anything else - we currently have dozens of open error reports with code “UNKNOWN” where the users have no idea on how to reproduce and we have no idea what the trigger may be. It would help tremendously if there was some way to encode the original error code into the message, even if it was just added into the error message, something like code: UNKNOWN, message: “unknown error (code 1224)” the error message would be infinitely more useful.

Considering windows has an absurd number of different error codes, I don’t have a lot of hope that all of them will eventually be mapped to sensible “generic” codes, I think a goal should be to make the unknown error case more useful.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 43 (19 by maintainers)

Commits related to this issue

Most upvoted comments

As long as they don’t collide with our own mappings, we could also return a negated error code, as on Unix, maybe?