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

--watch Now Throws an Error #8088

Closed
arb opened this issue Mar 8, 2019 · 37 comments · Fixed by #8258
Closed

--watch Now Throws an Error #8088

arb opened this issue Mar 8, 2019 · 37 comments · Fixed by #8258
Labels

Comments

@arb
Copy link

arb commented Mar 8, 2019

🐛 Bug Report

I recently updated jest to 24.3.1 and now running with --watch throws an error and does not start. The error is:

2019-03-08 09:51 node[1373] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
Error: Error watching file for changes: EMFILE
    at _errnoException (util.js:1022:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1359:9)

I do not have watchman installed globally and again, this was working yesterday and now it's not. I feel like it's an issue with the macOS update but I can't confirm. I know installing watchman via brew is a suggested solution but I've never had to do that before and that seems kind of like it's masking a possible issue with jest.

To Reproduce

npx jest --watch

Expected behavior

I expected jest to continue to work correctly as it has before I updated.

Link to repl or repo (highly encouraged)

https://github.com/arb/celebrate/tree/feature-ref this is the branch I'm working with and currently exhibiting the above behavior.

Run npx envinfo --preset jest

Paste the results here:

npx: installed 1 in 1.538s

  System:
    OS: macOS 10.14.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 8.11.1 - ~/.nvm/versions/node/v8.11.1/bin/node
    Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.1/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.11.1/bin/npm
  npmPackages:
    jest: ^24.3.1 => 24.3.1 
@arb arb added the 🐛 Bug label Mar 8, 2019
@SimenB
Copy link
Member

SimenB commented Mar 8, 2019

You can probably install watchman to get around this - brew install watchman.

This is probably because we removed the fsevents crawler (#8048). Not sure why the node crawler explodes, tho.

@arb
Copy link
Author

arb commented Mar 8, 2019

@SimenB I'd rather not do that. Like I said in the initial issue, that seems to be masking an actual issue with jest. If I install watchman, reproducing the problem becomes harder.

@SimenB
Copy link
Member

SimenB commented Mar 8, 2019

Sure, I was just trying to unblock you

@thymikee
Copy link
Collaborator

thymikee commented Mar 8, 2019

I tried to run it with yarn (so fresh install) and don't see the error – it's probably related to deps update, so please clean it up. However I can see the same message as here: #8084.

@thymikee
Copy link
Collaborator

thymikee commented Mar 8, 2019

Closing as duplicate of #8084

@thymikee thymikee closed this as completed Mar 8, 2019
@arb
Copy link
Author

arb commented Mar 8, 2019

@thymikee how is this a duplicate of #8084? The error message is completely different and I'm not using the --changedSince flag either.

@thymikee
Copy link
Collaborator

thymikee commented Mar 8, 2019

This is the error I get when running --watch on your repro, feature-ref branch:

 FAIL   test  test/celebrate.test.js
  ● Test suite failed to run

    TypeError: options.changedFiles.has is not a function

FYI --watch and --changedSince share a lot of logic.

@arb
Copy link
Author

arb commented Mar 8, 2019

I see. Thank you for the clarification! I didn't get that MUCH more specific error when I'm running locally, but I agree, the root cause seems to be the same as #8084.

@SimenB
Copy link
Member

SimenB commented Mar 12, 2019

Seems this is still an issue for folks

@SimenB SimenB reopened this Mar 12, 2019
@yoshicarroll
Copy link

It is, yes. Jest 23 worked fine. As soon as I updated to Jest 24 24.4.0 it started breaking.

@arb
Copy link
Author

arb commented Mar 13, 2019

@yoshicarroll what version of macOS are you running? I'm starting to think that is the common thread.

@yoshicarroll
Copy link

@arb High Sierra 10.13.6

@arb
Copy link
Author

arb commented Mar 13, 2019

Interesting, well it's not that then; I'm on 10.14.3.

@yoshicarroll
Copy link

I don't know anything about Jest internals, but if someone can point me to where to set a breakpoint and collect some info, I have some time to help out.

@elkwood
Copy link

elkwood commented Mar 14, 2019

I was able to alleviate the issue in my project that is experiencing this by configuring the watchPathIgnorePatterns to ["node_modules"]. As expected, this lowered the number of files being watched to something below my system's limit.

https://jestjs.io/docs/en/configuration.html#watchpathignorepatterns-array-string

@arb
Copy link
Author

arb commented Mar 15, 2019

Can confirm this workaround gets around the problem. Make sure you specify the value on the project config if you're using multiple projects. I still believe there needs to be a code fix for this as it was working in version 23, but this is a good workaround for the current problem! 👍

@yoshicarroll
Copy link

This workaround resolves the errors for me as well, thanks @elkwood.
And, like @arb I too believe a code fix should fix the underlying issue.

@SimenB
Copy link
Member

SimenB commented Mar 17, 2019

My guess is that this is caused by #8048. Maybe we can get sane to re-add fsevents seeing as it'll be easier to install in tue future?

@brneto
Copy link

brneto commented Mar 26, 2019

I had issue I see here using jest and the only way I could fix that was installing watchman.
Here my environment:

System:
    OS: macOS 10.14.3
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
  Binaries:
    Node: 11.12.0 - /usr/local/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.7.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.5.0 => 24.5.0 

If now is necessary we install watchman to run jest, why that information isn't in Jest website (or documentation)? I needed to do a long research till I get here. Including that information into Jest page installation instruction would make jest user's life a lot easier.

Why not just include this information somewhere in Jest website?

@BoraALAP
Copy link

I'm learning react and I was testing redux actions, I installed es-lint to project (for no reason) and start getting the same error. Deleted node-modules and removed es-lint from the project. Everything went back to normal. I don't think this information helps you at all :), but just wanted to let you know es-lint might be part of the issue as well for you guys too.

@gaearon
Copy link
Contributor

gaearon commented Apr 2, 2019

This issue is a blocker for next Create React App release, which by itself blocks several important updates (including React Hooks lint rules).

If we can't resolve it on the sane level, can we bring fsevents back into Jest directly?

I'm worried about the path forward here.

@SimenB
Copy link
Member

SimenB commented Apr 2, 2019

I wonder if we can solve this in sane with the next release of fsevents, which won't require building native dependencies (it'll use n-api).

EDIT: We can probably just vendor it for now, we already vendor their watchman implementation (https://github.com/facebook/jest/blob/2bc62803ba457a3139c9533835a6888a824ddf4f/packages/jest-haste-map/src/lib/WatchmanWatcher.js)

EDIT2: pasted wrong link above originally, now fixed

@scotthovestadt
Copy link
Contributor

@SimenB why are we watching node_modules by default? I understand doing it when Watchman makes it “free”, but otherwise...? Is there historical context I’m missing?

@thymikee
Copy link
Collaborator

thymikee commented Apr 2, 2019

@scotthovestadt you may ask @cpojer about that, but if we could only watch node_modules by default when watchman is enabled, that would be nice.

@scotthovestadt
Copy link
Contributor

Or just a shallow watch of the folder, which would be nice because it would catch new modules. I’ll take a look today.

@SimenB
Copy link
Member

SimenB commented Apr 2, 2019

No idea, maybe @cpojer can chime in. But I guess the point is, since watchman makes it free, they should behave as close as possible? If it's blocking CRA though, they can probably configure Jest to not watch node_modules?

@cpojer
Copy link
Member

cpojer commented Apr 2, 2019

People get upset when we aren't watching node_modules because people tend to change them manually.

@elkwood
Copy link

elkwood commented Apr 2, 2019

I'm not sure that ignoring node_modules will fix the issue for everyone who uses Jest. I can imagine large applications where you still reach the file system's watch limit even if you do ignore node_modules. Probably not the repo I'd want to maintain, but I'm sure they exist.

@scotthovestadt
Copy link
Contributor

@elkwood Yeah, going with an alternate solution (see #8258), may revisit defaults on watching node_modules in the future if have more issues in this area.

@SimenB
Copy link
Member

SimenB commented Apr 3, 2019

Fix out in 24.7.0

@baixiaoji
Copy link

baixiaoji commented Jun 4, 2019

having same error jest@24.8.0, but using 24.7.1 is ok

@SimenB
Copy link
Member

SimenB commented Jun 4, 2019

That's a different error then, please open up a new issue

@baixiaoji
Copy link

baixiaoji commented Jun 4, 2019

That's a different error then, please open up a new issue

so you already known the error? but I reinstall jest@24.8.0, the error has gone

@SimenB
Copy link
Member

SimenB commented Jun 4, 2019

No, but the error talked about in this issue has been fixed.

@normancarcamo
Copy link

I confirm that ignoring the node_modules worked again:

{
  "watchPathIgnorePatterns": ["node_modules"]
}

jest@24.8.0 doesn't solve the issue for me :/

@jeffbski-rga
Copy link

Problem still exists in jest@24.9.0 but configuring watchPathIgnorePatterns to ignore node_modules does fix.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.