Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extend-exclude = [
"**/*.snap",
"**/*/CHANGELOG.md",
"apps/oxlint/conformance/snapshot.md",
"apps/oxfmt/test/**/fixtures/**",
"crates/oxc_linter/fixtures",
"crates/oxc_linter/src/rules/eslint/no_undefined.rs",
"crates/oxc_linter/src/rules/eslint/no_unused_vars/ignored.rs",
Expand Down
11 changes: 11 additions & 0 deletions apps/oxfmt/src-js/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ import {
void (async () => {
const args = process.argv.slice(2);

// Node.js sets `stdio` to non-blocking mode,
// which causes `WouldBlock` errors in Rust when writing large output with `--stdin-filepath`.
// Set blocking mode before calling NAPI bindings.
// See: https://github.com/napi-rs/napi-rs/issues/1630
//
// NOTE: Unlike `yargs/set-blocking` which recommends calling just before `process.exit()`,
// we must set blocking mode here because Rust outputs during `runCli()` execution.
// See also: https://github.com/yargs/set-blocking
(process.stdout as any)._handle?.setBlocking?.(true);
(process.stderr as any)._handle?.setBlocking?.(true);

// Call the Rust CLI first, to parse args and determine mode
// NOTE: If the mode is formatter CLI, it will also perform formatting and return an exit code
const [mode, exitCode] = await runCli(
Expand Down
7 changes: 7 additions & 0 deletions apps/oxfmt/test/cli/stdin/__snapshots__/stdin.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ exports[`--stdin-filepath > should format TS code from stdin 1`] = `
"stdout": "const x: number = 1;",
}
`;

exports[`--stdin-filepath > should not report \`WouldBlock\` error on large file piped to wc 1`] = `
{
"exitCode": 0,
"stderr": "",
}
`;
Loading
Loading