diff --git a/src/bun.js/webcore/blob/write_file.zig b/src/bun.js/webcore/blob/write_file.zig index 90969e19e3..879dcebd02 100644 --- a/src/bun.js/webcore/blob/write_file.zig +++ b/src/bun.js/webcore/blob/write_file.zig @@ -350,6 +350,7 @@ pub const WriteFileWindows = struct { err: ?bun.sys.Error = null, total_written: usize = 0, event_loop: *jsc.EventLoop, + poll_ref: bun.Async.KeepAlive = .{}, owned_fd: bool = false, @@ -404,7 +405,7 @@ pub const WriteFileWindows = struct { }, } - write_file.event_loop.refConcurrently(); + write_file.poll_ref.ref(write_file.event_loop.virtual_machine); return write_file; } @@ -481,7 +482,6 @@ pub const WriteFileWindows = struct { fn mkdirp(this: *WriteFileWindows) void { log("mkdirp", .{}); this.mkdirp_if_not_exists = false; - this.event_loop.refConcurrently(); const path = this.file_blob.store.?.data.file.pathlike.path.slice(); jsc.Node.fs.Async.AsyncMkdirp.new(.{ @@ -494,8 +494,6 @@ pub const WriteFileWindows = struct { } fn onMkdirpComplete(this: *WriteFileWindows) void { - this.event_loop.unrefConcurrently(); - const err = this.err; this.err = null; if (err) |err_| { @@ -539,7 +537,6 @@ pub const WriteFileWindows = struct { } pub fn onFinish(container: *WriteFileWindows) WriteFileWindowsError { - container.event_loop.unrefConcurrently(); var event_loop = container.event_loop; event_loop.enter(); defer event_loop.exit(); @@ -623,6 +620,7 @@ pub const WriteFileWindows = struct { } this.file_blob.store.?.deref(); this.bytes_blob.store.?.deref(); + this.poll_ref.disable(); uv.uv_fs_req_cleanup(&this.io_request); bun.destroy(this); } diff --git a/test/regression/issue/23316-long-path-spawn.test.ts b/test/regression/issue/23316-long-path-spawn.test.ts index cac20887ad..5b60dde53e 100644 --- a/test/regression/issue/23316-long-path-spawn.test.ts +++ b/test/regression/issue/23316-long-path-spawn.test.ts @@ -89,7 +89,8 @@ test("spawn should handle cwd paths with disabled 8.3 names on Windows", async ( stdout: "inherit", stderr: "inherit", }); - await proc.exited; + const exitCode = await proc.exited; + if (exitCode !== 0) throw new Error("process exited"); } catch (e) { err = e; }