Add tracing to Bun.write operations

Added tracing in WriteFile.doWrite() to track all writes through
Bun.write, logging fd, buffer length, and bytes written/errno.

Verified fs tracing works with sync operations (openSync, writeSync, closeSync).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2025-10-27 18:23:42 +00:00
parent f419320a7a
commit 4d0ef56df7

View File

@@ -130,6 +130,15 @@ pub const WriteFile = struct {
// non-seekable file.
bun.sys.write(fd, buffer);
// Trace the write operation
if (Output.trace_enabled) {
const tracer = Output.tracer("bun_write");
switch (result) {
.result => |bytes| tracer.trace(.{ .call = "write", .fd = fd.cast(), .length = buffer.len, .bytes_written = bytes }),
.err => |err| tracer.trace(.{ .call = "write", .fd = fd.cast(), .length = buffer.len, .errno = err.errno }),
}
}
while (true) {
switch (result) {
.result => |res| {