Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ vergen-gitcl = { version = "1.0.8", features = ["cargo"] }
webbrowser = "1.0.6"

[patch.crates-io]
# TODO: Remove after https://github.com/notify-rs/notify/pull/981 is released.
notify = { git = "https://github.com/marcoshernanz/notify.git", rev = "8e42e82e0710643d8f85eba2b2086bf8fb1b8427" }
bincode = { git = "https://github.com/bgw/bincode.git", branch = "bgw/patches" }
virtue = { git = "https://github.com/bgw/virtue.git", branch = "bgw/fix-generic-default-parsing" }
# We have to very frequently bump the swc major version of mdxjs-rs
Expand Down
39 changes: 39 additions & 0 deletions turbopack/crates/turbo-tasks-fs/src/watcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,45 @@ mod tests {
.unwrap();
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn polling_detects_subsecond_mtime_changes() {
let tt = TurboTasks::new(TurboTasksBackend::new(
BackendOptions::default(),
noop_backing_storage(),
));
tt.run_once(async move {
let fs = MockFileSystem::new(DiskWatcherConfig {
recursive_mode: Some(DiskWatcherRecursiveMode::NonRecursive),
poll_interval: Some(Duration::from_millis(100)),
report_invalidation_reason: true,
});
let file_path = fs.root_path.join("file.txt");
let initial_mtime = SystemTime::UNIX_EPOCH
+ Duration::from_secs(1_000_000)
+ Duration::from_millis(100);
fs::write(&file_path, "initial")?;
fs::File::options()
.write(true)
.open(&file_path)?
.set_modified(initial_mtime)?;

DiskWatcher::start_watching(fs.clone()).await?;
assert_eq!(fs.tracked_read_strongly_consistent(&file_path).await, 1);

// Keep this mtime-only so the test never exposes a transient current-time mtime.
fs::File::options()
.write(true)
.open(&file_path)?
.set_modified(initial_mtime + Duration::from_millis(100))?;
wait_for_rerun(&fs, &file_path, 1).await;

fs.watcher.stop_watching().await;
anyhow::Ok(())
})
.await
.unwrap();
}

/// `recursive_mode` is set explicitly rather than left to the platform default so that both
/// watching strategies are covered on every host. `TURBO_TASKS_FORCE_WATCH_MODE` still
/// overrides it, collapsing these into two cases.
Expand Down
Loading