Skip to content

Commit

Permalink
fix(node): errno property when command missing (#22691)
Browse files Browse the repository at this point in the history
Fixes #22604

`remix dev` with Node adapter works:
```
$ ~/gh/littledivy/deno/target/debug/deno task dev
Task dev remix dev --manual

 💿  remix dev

 info  building...
 info  built (619ms)
[remix-serve] http://localhost:3000 (http://192.168.1.24:3000)

GET / 200 - - 3.090 ms
```
  • Loading branch information
littledivy authored Mar 4, 2024
1 parent 6650019 commit 5a28d70
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ext/node/polyfills/internal/child_process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ export class ChildProcess extends EventEmitter {
});
})();
} catch (err) {
this.#_handleError(err);
let e = err;
if (e instanceof Deno.errors.NotFound) {
e = _createSpawnSyncError("ENOENT", command, args);
}
this.#_handleError(e);
}
}

Expand Down
12 changes: 12 additions & 0 deletions tests/unit_node/child_process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,15 @@ Deno.test(async function execFileWithUndefinedTimeout() {
);
await promise;
});

Deno.test(async function spawnCommandNotFoundErrno() {
const { promise, resolve } = Promise.withResolvers<void>();
const cp = CP.spawn("no-such-command");
cp.on("error", (err) => {
const errno = Deno.build.os === "windows" ? -4058 : -2;
// @ts-ignore: errno missing from typings
assertEquals(err.errno, errno);
resolve();
});
await promise;
});

0 comments on commit 5a28d70

Please sign in to comment.