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

v1 addon build watching gets stuck in a loop #1770

Open
bendemboski opened this issue Jan 25, 2024 · 5 comments
Open

v1 addon build watching gets stuck in a loop #1770

bendemboski opened this issue Jan 25, 2024 · 5 comments

Comments

@bendemboski
Copy link
Contributor

bendemboski commented Jan 25, 2024

REPRO:

$ npx ember-cli@5.5 addon my-addon
$ cd my-addon
$ ember try:one embroider-optimized --- ember test -s

EXPECTED:
The build runs once, and only rebuilds when something in the addon is modified

ACTUAL:
The tests run, but there are continuous rebuilds in the background as the build watcher notices various changes in node_modules/.embroider

I reproduced this on MacOS with watchman installed, but I believe it will reproduce on any OS.

@mansona
Copy link
Member

mansona commented Feb 8, 2024

Does it also happen if you ran ember serve and went to localhost:4200/tests/ ?

@bendemboski
Copy link
Contributor Author

@mansona no it doesn't

@mansona
Copy link
Member

mansona commented Feb 8, 2024

Well that is fishy 🤔 Is there any specific reason why you would want to use the ember test -s version over ember serve? I'm not saying that we shouldn't fix it or anything, I'm just trying to find out use cases here so I can understand the depth of the problem

@bendemboski
Copy link
Contributor Author

Oh, a number of reasons:

  • It's how I've always done it, and how the pnpm test:ember scripts are set up in the blueprint (pnpm test:ember -s)
  • I often do ember test -s --filter 'some module or something'
  • It's closer to how things run in CI (I suppose I could do ember serve -e testing or something, but that's more stuff to type)
  • I'm building an Electron app, and when using ember-electron you have to use the ember electron:test command (which wraps the built-in test command and suffers from the same issue) -- there's no equivalent of running ember serve and visiting the test URL

@bendemboski
Copy link
Contributor Author

bendemboski commented Jun 1, 2024

Okay, I think I've finally gotten to the bottom of this and it's messy. I haven't had the chance to try this with watchers other than watchman, but I believe the root cause is that watchman by default ignores . directories, but only at the root of watched folders, e.g. if you watch /foo, it will ignore /foo/.something, but not /foo/bar/.something. So by default it does not ignore node_modules/.embroider.

The reason that this only reproduces with ember test -s and not ember serve is a happy accident -- ember serve adds an ignore path, while ember test -s doesn't, and only when any ignore paths are specified does this logic in sane activate and do its own checking, which apparently ignores any dot files/folders whether at the root or not. This is certainly a bug in sane, as the ignoring of dot files not at the root is determined by whether any ignore paths are present or not (probably the sane authors thought that watchman's dot file ignoring was not only for files at the root).

I think the solution here should be for ember-cli and/or embroider to not rely on the watcher ignoring the node_modules/.embroider directory, but to explicitly ensure that it is ignored. The most straightforward way I can see to do that is to add

ignored: [
  path.resolve(this.project.root, 'node_modules/.embroider'),
],

here and add

path.resolve(this.project.root, 'node_modules/.embroider'),

here (even though that's not strictly necessary to fix the bug). But that's kinda putting an embroider implementation detail in ember-cli...

I tried changing this to be a broccoli-funnel that excluded node_modules/.embroider, but that caused a severe build performance degradation.

So I'm not quite sure how to go about fixing this, and would love any thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants