Repository navigation
Remove the TS_STDIO autogate and the C++ stdio line buffer - #8865
Conversation
TS_STDIO is fully rolled out, so writes to the stdio file descriptors through node:fs are always line-buffered and logged by internal_fs_stdio.ts. Delete the gate, the tsStdio() binding, and StdioFile's line buffer and console.log path. StdioFile stays for fstat and reads, and now discards writes, which node:fs no longer sends it. The stdio suite runs in one cell instead of a C++ and a TypeScript cell, and gains a case for writevSync, callback write and writev, and fs.promises.writeFile, since a write API that stopped routing stdio to TypeScript would now lose its output silently. The re-entrancy regression test's comments describe the TypeScript path.
There was a problem hiding this comment.
Superseded by the review of
6633adce.
This review, of d247cce4
✅ Approved — No findings: the autogate and the C++ fallback are removed cleanly, every node:fs write API routes stdio fds to the TypeScript path, and the new tests cover the paths that no longer have a fallback.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The change removes re-entrant JS and microtask code from StdioFile, which takes away the code where the earlier use-after-free lived. The removed binding is not referenced anywhere.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
No leftover references to the gate or the binding remain. The stdio write routing is in place on every node:fs write path, the includes are kept or dropped correctly, and the merged test cell and its BUILD.bazel entry match each other.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The updated comments describe the code as it is now, and the one historical reference is explicitly introduced as history.
Reviewed commit: d247cce4
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8865 +/- ##
==========================================
- Coverage 69.89% 69.87% -0.02%
==========================================
Files 881 881
Lines 231960 231859 -101
Branches 33675 33656 -19
==========================================
- Hits 162122 162020 -102
- Misses 49873 49879 +6
+ Partials 19965 19960 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
# Conflicts: # src/workerd/io/worker-fs.c++
There was a problem hiding this comment.
✅ Approved — No findings. The merge from main in worker-fs.c++ keeps the simplified StdioFile, with no leftover line buffer, gate or binding, and the rest of the change is unchanged from the earlier clean review.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
StdioFile::write now discards its input. This removes the re-entrant console.log and microtask code, which is where the earlier use-after-free lived. No access control, validation or limit is weakened.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates are needed.
📋 Code Quality: ✅ LGTM
The merge result in src/workerd/io/worker-fs.c++ is clean:
StdioFilehas no leftovertype,lineBufferorweakThismembers.writediscards the data and returnsbuffer.size().getStdiobuilds the file withkj::rc<StdioFile>().weak-refs.his still used elsewhere in the file. The microtask-queue include was removed along with its only user.- Nothing in the tree still refers to
TS_STDIO,tsStdioorfs-stdio-ts.
⚡ Performance: ✅ LGTM
The per-write heap copy, the line buffer and the microtask scheduling are gone from StdioFile, so its write path is cheaper than before.
📝 Documentation: ✅ LGTM
The updated comments describe the code as it is now.
Reviewed commit: 6633adce
TS_STDIO (#8120) is fully rolled out, so this deletes the C++ it kept for rollback.
StdioFileloses its line buffer and console.log path, about 150 lines, and keeps fstat and EOF reads. Every node:fs API that writes to an fd (writeSync, writevSync, write, writev, writeFileSync, appendFileSync, writeFile, fs.promises.writeFile, and process.stdout through writeSync) already sends fds 0 to 2 tointernal_fs_stdio.ts, soStdioFile::writenow discards.The autogate and the
tsStdio()binding are removed. The C++ and TypeScript test cells forfs-stdio-test.jsare merged into one, and a new case covers writevSync, callback write and writev, and fs.promises.writeFile on stdio fds: with no C++ fallback, a write API that stopped routing stdio to TypeScript would drop its output without an error. The comments instdio-writesync-reentry-uaf-test.jsnow describe the TypeScript path; its test logic is unchanged.Embedders that never enabled the gate, including
workerd serve, switch to the TypeScript path with this change. Two visible differences: a partial line flushed outside a request is now logged instead of dropped, and a missingconsole.logno longer logs a warning. With no gate left, rollback is a revert.Tested:
bazel test //src/workerd/api/node/tests/... //src/workerd/api/tests/...and//src/workerd/io:worker-fs-test@, all variants. WithisStdioFdchanged to match no fd,fs-stdio-test@fails.