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

Error in watcher while editing a MD file #1208

Closed
drazik opened this Issue Nov 27, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@drazik
Contributor

drazik commented Nov 27, 2017

Hello,

When I edit some markdown files and save them, I randomly get the following error :

/home/drazik/workspace/blog/node_modules/@phenomic/core/lib/watch/index.js:120
      return file.name === filepath;
                  ^

TypeError: Cannot read property 'name' of undefined
    at /home/drazik/workspace/blog/node_modules/@phenomic/core/lib/watch/index.js:120:19
    at Array.find (native)
    at NodeWatcher.<anonymous> (/home/drazik/workspace/blog/node_modules/@phenomic/core/lib/watch/index.js:119:23)
    at NodeWatcher.emit (events.js:159:13)
    at NodeWatcher.rawEmitEvent (/home/drazik/workspace/blog/node_modules/sane/src/node_watcher.js:356:8)
    at NodeWatcher.<anonymous> (/home/drazik/workspace/blog/node_modules/sane/src/node_watcher.js:347:12)
    at ontimeout (timers.js:478:11)
    at tryOnTimeout (timers.js:302:5)
    at Timer.listOnTimeout (timers.js:262:5)

The phenomic version I use is 1.0.0-alpha.13. And my node version is 9.2.0.

It may be related to #1157 , but it is not really the same error.

@MoOx MoOx added the bug label Nov 27, 2017

@MoOx

This comment has been minimized.

Member

MoOx commented Nov 27, 2017

Looks like a bug. No way to reproduce with a hight percentage of failures?

@drazik

This comment has been minimized.

Contributor

drazik commented Nov 28, 2017

Actually it seems to be related to Vim. I explain myself :

In Vim, when I enter :w one time, there's no problem. But the second time, the error occurs.

In VS Code or in a random Linux text editor, there is absolutely no problem.

The only difference I know between Vim and others is that it writes some backup files when we save a file. I turned this off with set nobackup and set nowritebackup, and the error is gone.

@MoOx MoOx closed this in #1211 Dec 4, 2017

MoOx added a commit that referenced this issue Dec 4, 2017

`@phenomic/core`: Prevent watcher from crashing when a file is rename…
…d (or saved with vim) (#1211)

Fixes #1208
Fixes #1157

The `file` might be `undefined` if it's a temporary file that's deleted before the transformers run.

The watcher close function gets called with an undefined file sometimes when you rename/delete a file. The default Node.js fs.watch function is known for having some bugs, but adding an undefined check before deleting the file fixes the problem until the webpack team fixes it.

MoOx added a commit that referenced this issue Dec 4, 2017

`@phenomic/core`: Prevent watcher from crashing when a file is rename…
…d (or saved with vim) (#1211)

Fixes #1208
Fixes #1157

The `file` might be `undefined` if it's a temporary file that's deleted before the transformers run.

The watcher close function gets called with an undefined file sometimes when you rename/delete a file. The default Node.js fs.watch function is known for having some bugs, but adding an undefined check before deleting the file fixes the problem until the webpack team fixes it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment