Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@siketyan
Copy link
Member

@siketyan siketyan commented Sep 21, 2025

Summary

Fixed some workspace watcher tests that are failing on macOS. They have had two problems:

  • The fsevents API takes some time before it become able to catch filesystem events after added a target path. FYI, this doesn't occur with the kqueue backend.
  • The fsevents API catches a Modify(Data) event after the file is already deleted. It triggered the workspace to re-index the file.

Test Plan

I have tested on my own machine, and on GitHub Actions: https://github.com/biomejs/biome/actions/runs/17890793472/job/50870844033?pr=7549

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Sep 21, 2025

⚠️ No Changeset found

Latest commit: ed308ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the A-Project Area: project label Sep 21, 2025
@siketyan siketyan force-pushed the fix/failing-tests-on-macos branch from 1a5ace9 to 4735f02 Compare September 21, 2025 07:46
@siketyan siketyan self-assigned this Sep 21, 2025
@siketyan siketyan requested review from a team and arendjr September 21, 2025 07:46
@siketyan siketyan marked this pull request as ready for review September 21, 2025 07:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 21, 2025

Walkthrough

  • crates/biome_service/src/scanner/watcher.rs: In handle_notify_event the catch‑all for ModifyKind::Data(_), ModifyKind::Name(RenameMode::Any) and ModifyKind::Any now checks whether paths[0] exists; if it does it calls index_paths, otherwise it calls unload_paths. Event classification and error handling are unchanged; no public signatures were modified.
  • crates/biome_service/src/scanner/watcher.tests.rs: Two tests now insert a platform‑specific 1s sleep on Windows/macOS (replacing a prior 200ms delay in one case) to ensure the watcher sees events before proceeding.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "test: fix failing watcher tests on macOS" is concise and directly reflects the main change in the diff — fixes to watcher behaviour and test timing to address macOS fsevents quirks — so it clearly communicates the primary intent to a reviewer or teammate scanning history.
Description Check ✅ Passed The PR description succinctly summarises the problem (fsevents start-up delay and a spurious Modify(Data) after delete), the code and test changes made to address them, and includes a test plan with a GitHub Actions run, so it is directly related to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4735f02 and ed308ae.

📒 Files selected for processing (2)
  • crates/biome_service/src/scanner/watcher.rs (1 hunks)
  • crates/biome_service/src/scanner/watcher.tests.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_service/src/scanner/watcher.rs
  • crates/biome_service/src/scanner/watcher.tests.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
  • GitHub Check: Test Node.js API

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
crates/biome_service/src/scanner/watcher.rs (1)

193-200: Don’t hinge on the first path; partition by existence

Rare, but if a platform emits multiple paths for a Modify, basing the action on paths[0] could mishandle some entries. Partition and handle both buckets.

Try:

-                ModifyKind::Data(_) | ModifyKind::Name(RenameMode::Any) | ModifyKind::Any => {
-                    // It's possible to receive Modify(Data) event after the file is removed on macOS.
-                    let path = &paths[0];
-                    if workspace.fs().path_is_file(path) || workspace.fs().path_is_dir(path) {
-                        Self::index_paths(workspace, paths)
-                    } else {
-                        Self::unload_paths(workspace, paths)
-                    }
-                }
+                ModifyKind::Data(_) | ModifyKind::Name(RenameMode::Any) | ModifyKind::Any => {
+                    // On macOS, Modify(Data) can follow a removal; decide per path.
+                    let (existing, missing): (Vec<_>, Vec<_>) = paths
+                        .into_iter()
+                        .partition(|p| workspace.fs().path_is_file(p) || workspace.fs().path_is_dir(p));
+                    let mut diagnostics = Vec::new();
+                    if !existing.is_empty() {
+                        diagnostics.extend(Self::index_paths(workspace, existing)?);
+                    }
+                    if !missing.is_empty() {
+                        diagnostics.extend(Self::unload_paths(workspace, missing)?);
+                    }
+                    Ok(diagnostics)
+                }
crates/biome_service/src/scanner/watcher.tests.rs (1)

59-62: LGTM; macOS settle time is a pragmatic fix

The guarded 1s sleeps make the tests sane on FSEvents. Consider a tiny helper to de‑dupe and centralise the delay.

Apply this change and call it from both spots:

+#[cfg(target_os = "macos")]
+fn wait_for_fsevents_ready() {
+    sleep(Duration::from_secs(1));
+}
+
@@
-        #[cfg(target_os = "macos")]
-        sleep(Duration::from_secs(1));
+        #[cfg(target_os = "macos")]
+        wait_for_fsevents_ready();
@@
-        #[cfg(target_os = "macos")]
-        sleep(Duration::from_secs(1));
+        #[cfg(target_os = "macos")]
+        wait_for_fsevents_ready();

Also applies to: 129-131

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a683acc and 4735f02.

📒 Files selected for processing (2)
  • crates/biome_service/src/scanner/watcher.rs (1 hunks)
  • crates/biome_service/src/scanner/watcher.tests.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_service/src/scanner/watcher.rs
  • crates/biome_service/src/scanner/watcher.tests.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format all Rust source files before committing (just f)

Files:

  • crates/biome_service/src/scanner/watcher.rs
  • crates/biome_service/src/scanner/watcher.tests.rs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Place watcher tests for workspace methods in src/workspace/watcher.tests.rs
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/src/workspace_watcher.rs : Keep workspace state in sync with the filesystem using WorkspaceWatcher; only active in daemon mode
📚 Learning: 2025-08-11T11:53:15.299Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:53:15.299Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Place watcher tests for workspace methods in src/workspace/watcher.tests.rs

Applied to files:

  • crates/biome_service/src/scanner/watcher.tests.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: End-to-end tests
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix

@siketyan siketyan force-pushed the fix/failing-tests-on-macos branch from 4735f02 to ed308ae Compare September 21, 2025 08:03
@siketyan siketyan merged commit 8094579 into biomejs:main Sep 21, 2025
12 checks passed
kedevked pushed a commit to kedevked/biome that referenced this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants