nodejs / uvwasi

WASI syscall API built atop libuv
MIT License
225 stars 49 forks source link

fix: libuv can return UV_FILE or UV_TTY for FILE_TYPE_CHAR handles #179

Closed phated closed 1 year ago

phated commented 1 year ago

When uvwasi is used on Windows, it might be used in non-"ConsoleMode" and the uv_guess_handle function can return two different values for FILE_TYPE_CHAR because of that difference, see https://github.com/libuv/libuv/blob/v1.x/src/win/handle.c#L42-L47

This function can also return UV_FILE in the case of FILE_TYPE_DISK but I assume that a disk file will properly stat and there isn't a good way to figure out which one is being returned.

This fixes #157 (took me about a month of debugging)

phated commented 1 year ago

Thanks for the suggestion! I've merged it and I'll rebase once #180 lands.

cjihrig commented 1 year ago

It should be OK to rebase this now.

phated commented 1 year ago

Thanks @cjihrig! This has been rebased now. Cheers 🍻

phated commented 1 year ago

Excellent! We're actually using this through wasm-micro-runtime that uses uvwasi as an experimental WASI backend. And I'm writing bindings for OCaml, which is where I encountered this bug.

cjihrig commented 1 year ago

Oh that's cool. In that case, you won't have to wait for a Node release (which would probably be next year). I'll get a uvwasi release out today.

cjihrig commented 1 year ago

This is published in v0.0.14.