authorgravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-08-29 00:31:51+02:00
committergravatar for techatrix@mailbox.orgTechatrix <techatrix@mailbox.org> 2026-08-29 00:45:49+02:00
log88d0dbe9355fb17d24cab9861c692e89f32bbc7c
tree962b3232f9dbb31a155abce1eaccbfdc6d9e4b94
parent7c14270ed41314a97f17788569ec813755c07d4c
signature Signed by SSH key SHA256:HYC3SjXQcAt6uwv9pu/6OoVQ2rUH8rb5zKiUHSe9uxk

Maker: workaround file watching not supporting cancellation

Related https://codeberg.org/ziglang/zig/issues/31693

1 files changed, 15 insertions(+), 1 deletions(-)

lib/compiler/Maker.zig+15-1
......@@ -809,6 +809,11 @@ pub fn main(init: process.Init.Minimal) !void {
809809 var select: Io.Select(Event) = .init(io, &select_buffer);
810810 defer select.cancelDiscard();
811811
812 // File watching cannot be canceled without blocking
813 // https://codeberg.org/ziglang/zig/issues/31693
814 var is_fs_watching = false;
815 defer if (is_fs_watching) @panic("(zig build system) TODO file watching cannot be canceled without blocking");
816
812817 try select.concurrent(.message, Server.receiveMessage, .{s});
813818
814819 var in_debounce = false;
......@@ -816,8 +821,14 @@ pub fn main(init: process.Init.Minimal) !void {
816821 .message => |payload| {
817822 const header: Client.Message.Header = try payload;
818823 switch (header.tag) {
819 .exit => return cleanExit(io, &scanned_config),
824 .exit => {
825 // exit early until file watching supports cancelation without blocking
826 if (is_fs_watching) std.process.exit(0);
827 return cleanExit(io, &scanned_config);
828 },
820829 .bsp_build_steps => {
830 if (is_fs_watching) @panic("(zig build system) TODO file watching cannot be canceled without blocking");
831
821832 // Cancel existing file watching
822833 select.cancelDiscard();
823834 in_debounce = false;
......@@ -851,6 +862,7 @@ pub fn main(init: process.Init.Minimal) !void {
851862 &watch.?,
852863 if (in_debounce) .{ .ms = debounce_interval_ms } else .none,
853864 });
865 is_fs_watching = true;
854866 } else if (watch) |*w| {
855867 w.deinit();
856868 watch = null;
......@@ -862,6 +874,7 @@ pub fn main(init: process.Init.Minimal) !void {
862874 }
863875 },
864876 .fs_event => |payload| {
877 is_fs_watching = false;
865878 if (!Watch.have_impl) unreachable;
866879 switch (payload catch |err| switch (err) {
867880 error.MustReconfigure => {
......@@ -883,6 +896,7 @@ pub fn main(init: process.Init.Minimal) !void {
883896 &watch.?,
884897 if (in_debounce) .{ .ms = debounce_interval_ms } else .none,
885898 });
899 is_fs_watching = true;
886900 continue :loop try select.await();
887901 },
888902 }