From aecca1cdf4428c0ee60eaf9a37e2e0305e5d4d1e Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 25 Feb 2025 14:27:11 +0100 Subject: [PATCH] On mac, calling fsync on stdout/stderr when not isatty returns ENOTSUP (#5430) --- docs/project/changelog.md | 2 ++ src/js/streams.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/project/changelog.md b/docs/project/changelog.md index 094b23c2172..e5bada3e8c4 100644 --- a/docs/project/changelog.md +++ b/docs/project/changelog.md @@ -23,6 +23,8 @@ _Insert Date Here_ - {{ Fix }} `mountNativeFS` API now correctly propagates the error. {pr}`5434` - {{ Fix }} `registerJsModule()` now works with non-extensible JS objects, such as ES6 modules. {pr}`5452` +- {{ Fix }} The Pyodide CLI runner now works correctly on macs when stdout is + not a tty. {pr}`5430` - {{ Fix }} Since 0.27.1, Pyodide has been broken in iOS because iOS ships broken wasm-gc support. Pyodide feature detects whether the runtime supports wasm-gc and uses it if it is present. Unfortunately, iOS passes the feature diff --git a/src/js/streams.ts b/src/js/streams.ts index 439bbc1cf68..12daeb36604 100644 --- a/src/js/streams.ts +++ b/src/js/streams.ts @@ -9,7 +9,11 @@ function nodeFsync(fd: number): void { try { fs.fsyncSync(fd); } catch (e: any) { - if (e && e.code === "EINVAL") { + if (e?.code === "EINVAL") { + return; + } + // On mac, calling fsync on stdout/stderr when not isatty returns ENOTSUP + if (e?.code === "ENOTSUP" && (fd === 1 || fd === 2)) { return; } throw e;