Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/oxfmt/src-js/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ void (async () => {
const args = process.argv.slice(2);

// Node.js sets non-TTY `stdio` to non-blocking mode,
// which causes `WouldBlock` errors in Rust when writing large output with `--stdin-filepath`.
// https://github.com/oxc-project/oxc/issues/17939 (issue was on macOS)
//
// which causes `WouldBlock` errors in Rust.
// As a workaround, if used with pipe, set blocking mode before calling NAPI bindings.
// See: https://github.com/napi-rs/napi-rs/issues/1630
//
// stdout: Writing large formatted output via `--stdin-filepath` can overflow the pipe buffer.
// https://github.com/oxc-project/oxc/issues/17939 (observed on macOS)
// @ts-expect-error: `_handle` is an internal API
if (!process.stdout.isTTY) process.stdout._handle?.setBlocking?.(true);
// stdin: In LSP mode (`--lsp`), VSCode communicates via stdin/stdout pipes.
// Rust reads stdin expecting blocking I/O, but non-blocking mode returns `EAGAIN` (os error 11).
// https://github.com/oxc-project/oxc/issues/20285
// @ts-expect-error: `_handle` is an internal API
if (!process.stdin.isTTY) process.stdin._handle?.setBlocking?.(true);

Expand Down
Loading