child_process: deliver ENOENT on nextTick
authorTimothy J Fontaine <tjfontaine@gmail.com>
Wed, 20 Nov 2013 16:49:40 +0000 (08:49 -0800)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Wed, 20 Nov 2013 17:35:08 +0000 (09:35 -0800)
After the uv upgrade, uv_spawn will now fail faster for certain
failures like ENOENT. However, our tests and other people may be
depending on that error being passed to the callback instead of a
throw.

lib/child_process.js

index 33928a9..96193a8 100644 (file)
@@ -952,7 +952,14 @@ ChildProcess.prototype.spawn = function(options) {
 
   var err = this._handle.spawn(options);
 
-  if (err) {
+  if (!constants)
+    constants = process.binding('constants');
+
+  if (-err == constants.ENOENT) {
+    process.nextTick(function() {
+      self._handle.onexit(err);
+    });
+  } else if (err) {
     // Close all opened fds on error
     stdio.forEach(function(stdio) {
       if (stdio.type === 'pipe') {