node-wasi icon indicating copy to clipboard operation
node-wasi copied to clipboard

Error: EISDIR: illegal operation on a directory, fstat

Open jtenner opened this issue 6 years ago • 1 comments

Hello! Great work on this project by the way.

In reference to #17 where the writes to stdout and stderr were returning 31.

Looks like

const stat = (wasi, fd) => {
  ...
  const stats = fs.fstatSync(entry.real);
  ...
};

Seems to be the trouble on windows. :)

When the file descriptor is 0, 1 or 2, it looks like an error code EISDIR is thrown because it's not an actual file descriptor on windows.

Perhaps there is a good way this can be fixed? I could help submit a pull request.

jtenner avatar Jul 16 '19 15:07 jtenner

If someone on windows wants to fix this I will gladly accept a PR.

Alternatively, a better solution might be to change fds 0, 1, and 2 to be streams, which would allow overriding them in the wasi constructor. This would also mean the defaults can be process.stdin and such so we wouldn't need to worry about platform specifics.

devsnek avatar Jul 16 '19 17:07 devsnek