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

Watcher issue on Window's short paths like C:\PROGRA~1\ #11679

Open
piotr-oles opened this issue Oct 14, 2020 · 20 comments
Open

Watcher issue on Window's short paths like C:\PROGRA~1\ #11679

piotr-oles opened this issue Oct 14, 2020 · 20 comments

Comments

@piotr-oles
Copy link

Bug report

What is the current behavior?
I'm an author of the fork-ts-checker-webpack-plugin and I noticed that behavior in my recent PR: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/pull/516/files.

When I navigate to a path using MS-DOS compatible path (for example temp directory on GitHub Actions on Windows image - C:\Users\RUNNER~1\AppData\Local\Temp\), and I add a directory to the compilation.contextDependencies (for example C:\Users\RUNNER~1\AppData\Local\Temp\my-app\src), webpack will trigger unnecessary rebuilds. I checked compiler.modifiedFiles and compiler.removedFiles and they randomly contain C:\Users\RUNNER~1\AppData\Local\Temp\my-app\src directory (which shouldn't be the case - there should be only files).

If the current behavior is a bug, please provide the steps to reproduce.

  1. Copy webpack project to C:\Program Files\my-app
  2. Add a hook that will add path.join(process.cwd, 'src') to compilation.contextDependencies
  3. Run webpack in a watch mode with CWD = C:\PROGRA~1\my-app
  4. Add/update/delete some files in C:\Program Files\my-app\src and debug compiler.modifiedFiles and compiler.removedFiles Set

What is the expected behavior?
As in webpack 4, the watcher should not trigger unnecessary rebuild and report directory as changed or removed file.

Other relevant information:
webpack version: 5.1.0
Node.js version: 10
Operating System: Windows 10
Additional tools:

@sokra
Copy link
Member

sokra commented Oct 15, 2020

I don't understand the problem. If you add src as contextDependency it will report src as changed once anything in src changes. And this also triggers a rebuild.
modifiedFiles will only list entries of fileDependencies or contextDependencies. It will not list the file changed if this is not a direct dependency.

@piotr-oles
Copy link
Author

piotr-oles commented Oct 15, 2020

I would expect that modifiedFiles and removedFiles contains a list of files - not directories. And that's the case on Linux, Mac, and Windows with normal paths, but not on Windows with MS-DOS compatible paths. It seems like related to webpack/watchpack#130

@alexander-akait
Copy link
Member

alexander-akait commented Oct 15, 2020

@piotr-oles how it is related to chokidar?

@piotr-oles
Copy link
Author

@evilebottnawi I didn't notice such an issue with webpack 4 which AFAIK uses chokidar as a low-level watching library. But I don't know if that's the source of the issue.

@alexander-akait
Copy link
Member

@piotr-oles

modifiedFiles will only list entries of fileDependencies or contextDependencies.

Expected, what do you want?

@piotr-oles
Copy link
Author

As I said above, it works differently on Linux and Mac OS. If it's expected, then the name ’modifiedFiles’ is misleading :)

@alexander-akait
Copy link
Member

@piotr-oles What is work differently? Yes, it is some misleading

@sokra
Copy link
Member

sokra commented Oct 15, 2020

I tried running the watchpack test suite within a 8.3 folder and there where no problems.

If it's expected, then the name ’modifiedFiles’ is misleading :)

yes maybe it's a bit off.

As I said above, it works differently on Linux and Mac OS

It should not do that.

@sokra
Copy link
Member

sokra commented Oct 15, 2020

But I really noticied a small difference when using 8.3 names. It reports C:\PROGRA~1 as removed as it wasn't able to find the folder with readdir...

@piotr-oles
Copy link
Author

Yes, there is something off with 8.3 names. I resolved an 8.3 path using fs.resolveSync.native in my tests as a CWD for the spawned webpack process and now they pass :)

@alexander-akait
Copy link
Member

@piotr-oles so we can close it?

@piotr-oles
Copy link
Author

It's up to you. The problem still exists, but I was able to do a workaround :)

@alexander-akait
Copy link
Member

@piotr-oles please describe what you expected, because

As I said above, it works differently on Linux and Mac OS

It should not do that.

@sokra
Copy link
Member

sokra commented Oct 16, 2020

I resolved an 8.3 path using fs.resolveSync.native in my tests

How did you do that exactly? I wasn't able to find fs.resolveSync.native?

@sokra
Copy link
Member

sokra commented Oct 16, 2020

ah it's fs.realpathSync.native

@piotr-oles
Copy link
Author

Yep, sorry for the wrong function :)

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@webpack-bot
Copy link
Contributor

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

@alexander-akait
Copy link
Member

still valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority - Low
Development

No branches or pull requests

4 participants