From 4d0ef56df71de1b26efa0bef24abce6ef951f91d Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Mon, 27 Oct 2025 18:23:42 +0000 Subject: [PATCH] Add tracing to Bun.write operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/bun.js/webcore/blob/write_file.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bun.js/webcore/blob/write_file.zig b/src/bun.js/webcore/blob/write_file.zig index 1cca85e294..0899b6f0a7 100644 --- a/src/bun.js/webcore/blob/write_file.zig +++ b/src/bun.js/webcore/blob/write_file.zig @@ -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| {