Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: turbo watch does not detect changes from IntelliJ IDEA #9463

Open
1 task done
giovannipiller opened this issue Nov 19, 2024 · 2 comments
Open
1 task done
Labels
kind: bug Something isn't working

Comments

@giovannipiller
Copy link

giovannipiller commented Nov 19, 2024

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

No reproduction. I understand this makes it impossible to debug, but wanted to keep track of the issue and help users with similar issues until it can be reproduced in a public repo. More details below.

Which canary version will you have in your reproduction?

2.3.1-canary.0

Enviroment information

turbo 2.3.0

CLI:
   Version: 2.3.0
   Path to executable: /.../node_modules/turbo-darwin-arm64/bin/turbo
   Daemon status: Running
   Package manager: npm

Platform:
   Architecture: aarch64
   Operating system: macos
   WSL: false
   Available memory (MB): 33039
   Available CPU cores: 10

Environment:
   CI: None
   Terminal (TERM): xterm-256color
   Terminal program (TERM_PROGRAM): Apple_Terminal
   Terminal program version (TERM_PROGRAM_VERSION): 455
   Shell (SHELL): /bin/zsh
   stdin: false

-----

IntelliJ IDEA 2024.3

Expected behavior

When saving changes to a file (e.g. removing a single character) using IntelliJ, turbo watch reacts to the changes and restarts any affected package task.

Actual behavior

On IntelliJ Idea, sometimes, turbo watch doesn't detect changes after saving a file.

To Reproduce

Attempting to replicate the issue on an example repository has proven unsuccessful.
Since this is happening on a private mono-repo, with many thousands of files involved and ~100 of packages, I suspect it might be related to the amount of files that are being watched.

This used to work fine until [email protected], but as far as I can tell it started breaking from [email protected].
Further testing pinpointed the issue to [email protected].

That being said, I'm able to reproduce the issue only on IntelliJ Idea, since making the same changes on Visual Studio Code works fine.

Workaround and possible source cause

From what I gathered, it looks like the issue is reproducible on my repo only when the Back up files before saving option of IntelliJ Idea is turned on.
This option can be disabled from Preferences -> Appearance & Bahavior -> System Settings.

Back up files before saving
Before saving the file, create a backup. If the save operation is successful, IntelliJ IDEA deletes the backup. If not, it restores the contents of the original file from backup. This behavior is known as "safe write", and it prevents losing your file in case of a faulty save operation.

What this does in practice (e.g. when saving myfile.ts), is creating a temporary file called myfile.ts~backing up the original data until the save is successful .

Could this temporary file be messing with turbo's watcher?

Additional context

No persistent tasks are involved.
The watched tasks are straight up builds and rely turbo to watch for changes and restart.

@giovannipiller giovannipiller added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels Nov 19, 2024
@chris-olszewski
Copy link
Member

Thank you for tracking down the version you noticed this behavior. This is probably related to #9228, but nothing is immediately jumping out at me.

What this does in practice (e.g. when saving myfile.ts), is creating a temporary file called myfile.ts~backing up the original data until the save is successful.

I know fsevents has requires some special casing for file renames (which I'm assuming is the final step: mv myfile.ts~backup myfile.ts), but I'm not sure why any of the changes in 2.1.4-canary.5 would make this matter.

If you would be able to get the logs from the logfile displayed by turbo daemon status that might be helpful to figure out what FS operations are getting reported.

@chris-olszewski chris-olszewski removed the needs: triage New issues get this label. Remove it after triage label Nov 19, 2024
@giovannipiller
Copy link
Author

Here are the logs whenever the change is not detected.
In this scenario I deleted a space within a string.

e.g. 'aa aa' -> 'aaaa'

2024-11-19T15:14:41.787127Z  WARN turborepo_lib::package_changes_watcher: changed_files: {AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx"), AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx~")}
2024-11-19T15:14:41.787150Z  WARN turborepo_lib::package_changes_watcher: changed_packages: Ok(Some({WorkspacePackage { name: Other("packages/mypackage"), path: AnchoredSystemPathBuf("packages/mypackage") }: FileChanged { file: AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx~") }}))
2024-11-19T15:14:41.887934Z  WARN turborepo_lib::package_changes_watcher: changed_files: {AnchoredSystemPathBuf(".idea/workspace.xml~")}
2024-11-19T15:14:41.887946Z  WARN turborepo_lib::package_changes_watcher: changed_packages: Ok(Some({WorkspacePackage { name: Root, path: AnchoredSystemPathBuf("") }: FileChanged { file: AnchoredSystemPathBuf(".idea/workspace.xml~") }}))

Side note: .idea/workspace.xml is a file containing IntelliJ's workspace information. This is often modified by the IDE, which is why it's present in these logs, but I don't think it should have any impact.


As a reference, these are the logs whenever a change to the same file is properly detected.

2024-11-19T15:25:20.087636Z  WARN turborepo_lib::package_changes_watcher: changed_files: {AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx~"), AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx")}
2024-11-19T15:25:20.087648Z  WARN turborepo_lib::package_changes_watcher: changed_packages: Ok(Some({WorkspacePackage { name: Other("packages/mypackage"), path: AnchoredSystemPathBuf("packages/mypackage") }: FileChanged { file: AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx") }}))
2024-11-19T15:25:20.187595Z  WARN turborepo_lib::package_changes_watcher: changed_files: {AnchoredSystemPathBuf(".idea/workspace.xml~"), AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx"), AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx~")}
2024-11-19T15:25:20.187607Z  WARN turborepo_lib::package_changes_watcher: changed_packages: Ok(Some({WorkspacePackage { name: Root, path: AnchoredSystemPathBuf("") }: FileChanged { file: AnchoredSystemPathBuf(".idea/workspace.xml~") }, WorkspacePackage { name: Other("packages/mypackage"), path: AnchoredSystemPathBuf("packages/mypackage") }: FileChanged { file: AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx~") }}))

And these are for the same interaction on [email protected], where changes are detected as expected.

2024-11-19T15:57:16.749751Z  WARN turborepo_lib::package_changes_watcher: changed_files: {AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx"), AnchoredSystemPathBuf("packages/mypackage/src/MyComponent/MyComponentMenuTeam.tsx~")}
2024-11-19T15:57:16.749769Z  WARN turborepo_lib::package_changes_watcher: changed_packages: Ok(Some({WorkspacePackage { name: Other("packages/mypackage"), path: AnchoredSystemPathBuf("packages/mypackage") }}))
2024-11-19T15:57:16.949665Z  WARN turborepo_lib::package_changes_watcher: changed_files: {AnchoredSystemPathBuf(".idea/workspace.xml~")}
2024-11-19T15:57:16.949674Z  WARN turborepo_lib::package_changes_watcher: changed_packages: Ok(Some({WorkspacePackage { name: Root, path: AnchoredSystemPathBuf("") }}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants