aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpackages/bun-error/bun.lockbbin11916 -> 11916 bytes
-rw-r--r--src/css_scanner.zig6
-rw-r--r--src/http.zig11
-rw-r--r--src/javascript/jsc/javascript.zig3
-rwxr-xr-xsrc/node-fallbacks/bun.lockbbin42591 -> 42591 bytes
-rw-r--r--src/watcher.zig21
6 files changed, 29 insertions, 12 deletions
diff --git a/packages/bun-error/bun.lockb b/packages/bun-error/bun.lockb
index d46f3f2aa..6d7eec676 100755
--- a/packages/bun-error/bun.lockb
+++ b/packages/bun-error/bun.lockb
Binary files differ
diff --git a/src/css_scanner.zig b/src/css_scanner.zig
index aa5062cbb..10f065058 100644
--- a/src/css_scanner.zig
+++ b/src/css_scanner.zig
@@ -1206,7 +1206,7 @@ pub fn NewBundler(
while (this.import_queue.readItem()) |item| {
const watcher_id = this.watcher.indexOf(item) orelse unreachable;
const watch_item = this.watcher.watchlist.get(watcher_id);
- const source = try this.getSource(watch_item.file_path, watch_item.fd);
+ const source = try this.getSource(watch_item.file_path, if (watch_item.fd > 0) watch_item.fd else null);
css.source = &source;
try css.scan(log, allocator, &did_warn_tailwind);
}
@@ -1230,7 +1230,7 @@ pub fn NewBundler(
const item = this.bundle_queue.items[@intCast(usize, i)];
const watcher_id = this.watcher.indexOf(item) orelse unreachable;
const watch_item = this.watcher.watchlist.get(watcher_id);
- const source = try this.getSource(watch_item.file_path, watch_item.fd);
+ const source = try this.getSource(watch_item.file_path, if (watch_item.fd > 0) watch_item.fd else null);
css.source = &source;
const file_path = fs.relativeTo(watch_item.file_path);
if (hot_module_reloading and FeatureFlags.css_supports_fence) {
@@ -1255,7 +1255,7 @@ pub fn NewBundler(
};
}
- pub fn getSource(this: *CSSBundler, url: string, input_fd: StoredFileDescriptorType) !logger.Source {
+ pub fn getSource(this: *CSSBundler, url: string, input_fd: ?StoredFileDescriptorType) !logger.Source {
const entry = try this.fs_reader.readFile(this.fs, url, 0, true, input_fd);
const file = Fs.File{ .path = Fs.Path.init(url), .contents = entry.contents };
return logger.Source.initFile(file, this.allocator);
diff --git a/src/http.zig b/src/http.zig
index a2870a345..c624c9bd6 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -1813,8 +1813,10 @@ pub const RequestContext = struct {
};
const hash = Watcher.getHash(result.file.input.text);
- var watcher_index = ctx.watcher.indexOf(hash);
- var input_fd = if (watcher_index) |ind| ctx.watcher.watchlist.items(.fd)[ind] else null;
+ const input_fd = if (ctx.watcher.indexOf(hash)) |ind|
+ if (ind > 0) ctx.watcher.watchlist.items(.fd)[ind] else null
+ else
+ null;
if (resolve_result.is_external) {
try ctx.sendBadRequest();
@@ -2560,6 +2562,11 @@ pub const Server = struct {
Output.prettyErrorln("<r><d>File changed: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
}
} else {
+ if (event.op.move) {
+ var fds = ctx.watcher.watchlist.items(.fd);
+ fds[event.index] = 0;
+ }
+
const change_message = Api.WebsocketMessageFileChangeNotification{
.id = id,
.loader = (ctx.bundler.options.loaders.get(path.ext) orelse .file).toAPI(),
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig
index 520ac2d7a..844ffea92 100644
--- a/src/javascript/jsc/javascript.zig
+++ b/src/javascript/jsc/javascript.zig
@@ -1138,7 +1138,8 @@ pub const VirtualMachine = struct {
if (vm.watcher) |watcher| {
if (watcher.indexOf(hash)) |index| {
- fd = watcher.watchlist.items(.fd)[index];
+ const _fd = watcher.watchlist.items(.fd)[index];
+ fd = if (_fd > 0) _fd else null;
package_json = watcher.watchlist.items(.package_json)[index];
}
}
diff --git a/src/node-fallbacks/bun.lockb b/src/node-fallbacks/bun.lockb
index b81a09479..ee520ebd7 100755
--- a/src/node-fallbacks/bun.lockb
+++ b/src/node-fallbacks/bun.lockb
Binary files differ
diff --git a/src/watcher.zig b/src/watcher.zig
index fc8ae5308..7aa5c2ccf 100644
--- a/src/watcher.zig
+++ b/src/watcher.zig
@@ -75,8 +75,8 @@ pub const INotify = struct {
var watch_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0);
- const watch_file_mask = IN_EXCL_UNLINK | IN_MOVE_SELF | IN_DELETE_SELF | IN_CLOSE_WRITE;
- const watch_dir_mask = IN_EXCL_UNLINK | IN_DELETE | IN_DELETE_SELF | IN_CREATE | IN_MOVE_SELF | IN_ONLYDIR;
+ const watch_file_mask = IN_EXCL_UNLINK | IN_MOVE_SELF | IN_DELETE_SELF | IN_CLOSE_WRITE | IN_MOVED_TO;
+ const watch_dir_mask = IN_EXCL_UNLINK | IN_DELETE | IN_DELETE_SELF | IN_CREATE | IN_MOVE_SELF | IN_ONLYDIR | IN_MOVED_TO;
pub fn watchPath(pathname: [:0]const u8) !EventListIndex {
std.debug.assert(loaded_inotify);
@@ -222,6 +222,7 @@ pub const WatchEvent = struct {
.delete = this.op.delete or other.op.delete,
.metadata = this.op.metadata or other.op.metadata,
.rename = this.op.rename or other.op.rename,
+ .move = this.op.move or other.op.move,
.write = this.op.write or other.op.write,
};
}
@@ -233,6 +234,7 @@ pub const WatchEvent = struct {
.delete = (kevent.fflags & std.c.NOTE_DELETE) > 0,
.metadata = (kevent.fflags & std.c.NOTE_ATTRIB) > 0,
.rename = (kevent.fflags & std.c.NOTE_RENAME) > 0,
+ .move = false, // unhandled
.write = (kevent.fflags & std.c.NOTE_WRITE) > 0,
},
.index = @truncate(WatchItemIndex, kevent.udata),
@@ -245,7 +247,8 @@ pub const WatchEvent = struct {
.delete = (event.mask & INotify.IN_DELETE_SELF) > 0 or (event.mask & INotify.IN_DELETE) > 0,
.metadata = false,
.rename = (event.mask & INotify.IN_MOVE_SELF) > 0,
- .write = (event.mask & INotify.IN_MODIFY) > 0 or (event.mask & INotify.IN_MOVE) > 0,
+ .move = (event.mask & INotify.IN_MOVED_TO) > 0,
+ .write = (event.mask & INotify.IN_MODIFY) > 0,
},
.index = index,
};
@@ -256,6 +259,7 @@ pub const WatchEvent = struct {
metadata: bool = false,
rename: bool = false,
write: bool = false,
+ move: bool = false,
};
};
@@ -472,10 +476,10 @@ pub fn NewWatcher(comptime ContextType: type) type {
}
}
- pub fn indexOf(this: *Watcher, hash: HashType) ?usize {
+ pub fn indexOf(this: *Watcher, hash: HashType) ?u32 {
for (this.watchlist.items(.hash)) |other, i| {
if (hash == other) {
- return i;
+ return @truncate(u32, i);
}
}
return null;
@@ -491,7 +495,12 @@ pub fn NewWatcher(comptime ContextType: type) type {
package_json: ?*PackageJSON,
comptime copy_file_path: bool,
) !void {
- if (this.indexOf(hash) != null) {
+ if (this.indexOf(hash)) |index| {
+ // On Linux, the file descriptor might be out of date.
+ if (fd > 0) {
+ var fds = this.watchlist.items(.fd);
+ fds[index] = fd;
+ }
return;
}