Repository navigation
Report writes the host refuses - #19
Conversation
…d force instead of losing it.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
| Layer / File(s) | Summary |
|---|---|
Backend write error reporting src/fs.ts, src/node.ts |
Backend and VFS expose the backend’s write error code. NodeBackend records the error code when a write fails. |
Flush error handling src/natives/io.ts, src/natives/nio.ts |
flush returns whether buffered writes succeed. closeFd, FileDescriptor.sync0, and force0 handle flush failures by throwing I/O errors. |
Write failure parity test test/full/Full.java, test/programs.test.ts |
The Java test exercises writes followed by close, sync, or force. The Linux-only test compares output and exit status with HotSpot under a 4 KB file-size limit. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related PRs
- Project516/java-web#8: Adds the
Backend.chmodcontract andNodeBackend.chmodimplementation, which PR#19uses in its flush path. - Project516/java-web#75: Changes
closeFdfor socket descriptors and retains the file-descriptor flush path for non-socket descriptors.
Suggested reviewers: project516-review-bot
Merge Risk: 
Moderate · previous review f86e7
-
The change makes failed host writes surface as IOException in most close, sync and force paths. Mapped-buffer force can still report success after a refused write, and a descriptor whose close failed can later report a successful sync. Both leave silent data-loss paths in the feature this PR adds, so they should be fixed before merge.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description explains the change in detail. It says java-web buffers file writes and drops them on failure, and that close, FileDescriptor.sync and FileChannel.force returned normally. It also covers the fix. flush returns whether the host accepted the bytes, the host backend keeps the errno of the last failed write per path, and close, sync0 and force0 throw IOException with the errno message. It notes the behavior differences from HotSpot and the new ulimit-based test. This matches the changeset in src/fs.ts, src/natives/io.ts, src/natives/nio.ts, src/node.ts and the new test files.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 6 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Simplify code
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit taps the buffer twice,
Then checks the write and names the price.
If bytes cannot make it through,
An I/O error comes into view.
Close, sync, and force all tell,
While test runs match HotSpot well.
There was a problem hiding this comment.
The PR propagates host write errors (ENOSPC, EFBIG, EDQUOT, etc.) through flush, sync, force, and close by making flush return a boolean, adding flushOrThrow that throws IOException with the errno message, and wiring it into FileDescriptor.sync0, FileDescriptor.close0, and FileChannel.force0. A new test runs under ulimit -f 4 and matches HotSpot output.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
…uffer.force, and invalidate a descriptor before a close that can throw.
There was a problem hiding this comment.
The PR adds proper error propagation for failed writes (disk full, file too large, quota). Buffered writes now report errors at explicit flush/sync/force/close via IOException with the correct errno message, while implicit flushes (stat, open, rename) keep bytes buffered and retry later. The Backend interface and NodeBackend now track write errors per path using a Map, clearing on successful write. A new test verifies behavior matches HotSpot under ulimit -f. Earlier review concerns about cross-file error contamination have been addressed: NodeBackend.write clears the error on success (line 75), and the Backend.writeError method takes a path parameter for per-file tracking.
Not approved: 3 earlier points are still open in the threads.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict comment
java-web buffers a file's writes and writes them out on flush or close. When the host refused them (disk full, file too large, quota), the bytes were dropped and
close(),FileDescriptor.sync()andFileChannel.force()still returned normally, so a program believed a truncated file was complete.flushreturns whether the host took the bytes, and the host backend keeps the errno of the last failed write per path.close(FileDescriptor and channel closes),sync0andforce0throwIOExceptionwith the errno's message, such as "File too large" or "No space left on device". The descriptor is still closed, as with close(2), and the JavaFileDescriptoris invalidated before the close can throw.MappedByteBuffer.force()reports a failed write-back the same way; unmapping does not, as munmap does not. Implicit flushes (a stat or open of the same path) keep the bytes buffered and retry later instead of throwing.HotSpot reports such an error from
write(); java-web reports it at the next flush, sync, force or close, so code between the write and the close still runs. A program that wraps the write and the close in one try, as most do, sees the same exception.A new test runs a program under
ulimit -f 4(with SIGXFSZ ignored, writes past 4 KB fail with EFBIG) and compares close, sync and force with HotSpot; it fails without this change.Verified: the new test,
pnpm typecheck.