content icon indicating copy to clipboard operation
content copied to clipboard

Parenthesis the file path prevent hot reloading of content

Open weotch opened this issue 3 years ago • 6 comments

Version

@nuxt/content: 1.14.0 nuxt: 2.15.7

Steps to reproduce

Create a Nuxt + @nuxt/content project in directory where some ancestor has parenthesis in the name. For example, ~/Work (Open Source)/my-project

What is Expected?

When I change text in .md or .yml files within the content directory, for the changes to hot reload in my browser when as long as yarn dev is running.

What is actually happening?

Content changes do not hot reload. I need to restart yarn dev before the changes appear in browser. And they do appear on restart of Nuxt. This seems to be an issue only with the hot reloading of content feature. When I move the same project out of a file path containing parenthesis, it works as expected.

weotch avatar Oct 13 '21 14:10 weotch

@weotch

This seems to be an issue only with the hot reloading of content feature.

Just in case, do you mean that hot reload works when you edit other files than markdown files in content directory, even if the project root is in directory where some ancestor has parenthesis in the name?

nozomuikuta avatar Oct 15 '21 12:10 nozomuikuta

I meant that hot reload of Vue components works fine, like if I edit components of the Nuxt project that is using @nuxt/content.

weotch avatar Oct 15 '21 15:10 weotch

@weotch

TL;DR

At the moment, you can't enjoy hot-reloading of files in content directory, if parentheses are included in ancestor directory names.


Spending whole Saturday (I was not so productive 😇), finally I found the root cause:

With parentheses in ancestor directory names, change events are not emitted by the file watcher. Since Nuxt Content hot-reloads UI in the browser, listening the events, it doesn't do anything if there is no event.

Nuxt Content uses chokidar, and the bug is in it. I already reported the bug to the upstream repository with reproduction demo. 😄


@Atinux @Tahul

Sorry to mention in the weekend.

JFYR, if Nuxt Content v2 and/or Docus depends on chokidar, they would have the same kind of limitation. I'm glad to write some notes about this limitation somewhere in docs, so let me know if you want.

~~Or, if you take it positively, it might the time to implement your own file watcher like unjs/watch.~~ ⬆️ Forgive me to say such a stupid thing. My brain is not working since it's almost 4 a.m. in my place.

...I don't know the way to break my habit that I can't sleep, if I find a bug report, until I fix a bug or at least find the root cause.

nozomuikuta avatar Oct 16 '21 18:10 nozomuikuta

Ha sorry for interrupting your Saturday with this 😓. I appreciate your investigation!

weotch avatar Oct 17 '21 20:10 weotch

No need to apologise for pinging on weekend @NozomuIkuta and thank you for investigating the issue :blush:

Docus and even Nuxt 3 is also using chokidar via unstorage: https://github.com/unjs/unstorage/blob/main/package.json#L43

We can track the issue you created and see if it can be solved: https://github.com/paulmillr/chokidar/issues/1165

I like the idea of unjs/watch but Paul Miller is doing a great job with chokidar and this kind of tool take a lot of time, no need to re-invent the wheel but instead helping on other open source projects.

cc @pi0 (FYI)

atinux avatar Oct 17 '21 21:10 atinux

@weotch

Ha sorry for interrupting your Saturday with this 😓. I appreciate your investigation!

There is definitely no problem on your side. 🙌 Sorry, my words were not enough.

I'm glad to help people in any way I can do. In some meaning, contributing to OSS and playing TV games on weekends are just same kind of thing to me.

My bad is that I tend to play these games too much until I get win some medals. 😅

nozomuikuta avatar Oct 21 '21 18:10 nozomuikuta