Skip to content

Remove the TS_STDIO autogate and the C++ stdio line buffer - #8865

Merged
ry merged 2 commits into
mainfrom
ry/rm-ts-stdio-gate
Nov 26, 2026
Merged

ry merged 2 commits into
mainfrom
ry/rm-ts-stdio-gate

Conversation

@ry

@ry ry commented Nov 24, 2026

Copy link
Copy Markdown
Member

TS_STDIO (#8120) is fully rolled out, so this deletes the C++ it kept for rollback. StdioFile loses 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 to internal_fs_stdio.ts, so StdioFile::write now discards.

The autogate and the tsStdio() binding are removed. The C++ and TypeScript test cells for fs-stdio-test.js are 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 in stdio-writesync-reentry-uaf-test.js now 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 missing console.log no 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. With isStdioFd changed to match no fd, fs-stdio-test@ fails.

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.
@ry
ry requested review from a team as code owners November 24, 2026 06:53

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.87%. Comparing base (859fc5e) to head (6633adc).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
src/workerd/io/worker-fs.c++ 50.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# Conflicts:
#	src/workerd/io/worker-fs.c++

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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:

  • StdioFile has no leftover type, lineBuffer or weakThis members.
  • write discards the data and returns buffer.size().
  • getStdio builds the file with kj::rc<StdioFile>().
  • weak-refs.h is 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, tsStdio or fs-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

@ry
ry enabled auto-merge November 26, 2026 15:09
@ry
ry merged commit 6e8333e into main Nov 26, 2026
37 of 39 checks passed
@ry
ry deleted the ry/rm-ts-stdio-gate branch November 26, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants