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

Error in jest watch when using yarn for dependency installation #1474

Closed
aztecrex opened this issue Jan 31, 2017 · 20 comments
Closed

Error in jest watch when using yarn for dependency installation #1474

aztecrex opened this issue Jan 31, 2017 · 20 comments

Comments

@aztecrex
Copy link

aztecrex commented Jan 31, 2017

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

Can you reproduce the problem with latest npm?

Can you still reproduce it?

Yes.

Description

npm test, yarnpkg test, yarn test all fail when dependencies are installed with
yarn install. They all work fine when dependencies are installed with npm install.

In CI mode (not watched), tests run fine after installing deps with yarn. Research indicates others are having similar problems with tools like Watchman which leads me to believe that something is different in how Jest is performing the watch depending on how it is installed. There is also a
sense that this has to do with OSX Sierra.

Expected behavior

Tests run

Actual behavior

Crash. See stack trace beow.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts: react-scripts@0.8.5
  2. node -v: v7.4.0
  3. npm -v: 4.1.2

Then, specify:

  1. Operating system: Darwin trefoil 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

  2. Browser and version: Not a browser isssue

Reproducible Demo

Easy: this happens from a fresh create-react-app when Yarn (freshly brewed today)
is installed. yarnpkg test will fail. Now delete node_modules and run
npm install now npm test works fine. delete node_modues and run
yarn install, bad behavior returns.

Push to GitHub and paste the link here.

https://github.com/aztecrex/demo-create-react-app-yarn-problem

Full stack trace:

2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-01-30 18:58 node[77220] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1022:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1283:11)
error Command failed with exit code 1.
@gaearon
Copy link
Contributor

gaearon commented Jan 31, 2017

Can you check if node_modules/fsevents exists after installing with either Yarn or npm?

@robertlyall
Copy link

I'm having the same problem with version 1.0.3.

fsevents existed in my node_modules directory after installing with npm install, yarn install and yarnpkg install, however I could only run tests after installing with npm.

@gaearon
Copy link
Contributor

gaearon commented Jan 31, 2017

Which version of Yarn are you using?

@gaearon gaearon closed this as completed Jan 31, 2017
@gaearon gaearon reopened this Jan 31, 2017
@robertlyall
Copy link

I'm using Yarn version 0.19.1.

@gaearon
Copy link
Contributor

gaearon commented Jan 31, 2017

Could this be a regression? Would you mind installing 0.18 and trying again?

@robertlyall
Copy link

robertlyall commented Jan 31, 2017

Experiencing the same problem with 0.18.0, 0.18.1 and 0.20.0.

It may be worth noting that I'm using Yarn installed globally via NPM. I can try again using Homebrew if you'd like?

@aztecrex
Copy link
Author

aztecrex commented Jan 31, 2017

The one giving me trouble is 0.19.1 installed via Homebrew. That was my first version so can't brew switch

@gaearon
Copy link
Contributor

gaearon commented Jan 31, 2017

Can you figure out what the difference between installs produced by Yarn and npm is? Is some package or binary missing?

@robertlyall
Copy link

robertlyall commented Jan 31, 2017

I'm not sure what's the best way to do that. Do you have any suggestions?

I ran npm ls after yarn install and saw the following error:

npm ERR! extraneous: node-pre-gyp@0.6.32 /path/to/project/node_modules/node-pre-gyp

npm start does not show the same error. I don't know whether this error is important or not.

@hongrich
Copy link

Is this the same as #871? Maybe try installing watchman?

@aztecrex
Copy link
Author

aztecrex commented Jan 31, 2017

i just pushed the repo with both node_modules and a diff, https://github.com/aztecrex/demo-create-react-app-yarn-problem. Interesting, here is the result of du -sh *

 60K	README.md
 11M	node_modules.diff
127M	node_modules.npm
531M	node_modules.yarn
4.0K	package.json
 32K	public
 24K	src

(node_modules_diff is just the text output of diff -r node_modules.*)

@aztecrex
Copy link
Author

aztecrex commented Jan 31, 2017

@hongrich i had tried that yesterday. I just tried it again: install watchman, delete node_modules, yarn install. I get many warnings before jest gives me the watch UI, for example:

jest-haste-map: duplicate manual mock found:
  Module name: fetchWithRetries
  Duplicate Mock path: /Users/aztecrex/Working/demo-create-react-app-yarn-problem/node_modules.npm/fbjs/lib/__mocks__/fetchWithRetries.js
This warning is caused by two manual mock files with the same file name.
Jest will use the mock file found in:
/Users/aztecrex/Working/demo-create-react-app-yarn-problem/node_modules.npm/fbjs/lib/__mocks__/fetchWithRetries.js
 Please delete one of the following two files:
 /Users/aztecrex/Working/demo-create-react-app-yarn-problem/node_modules.yarn/fbjs/lib/__mocks__/fetchWithRetries.js
/Users/aztecrex/Working/demo-create-react-app-yarn-problem/node_modules.npm/fbjs/lib/__mocks__/fetchWithRetries.js

When i press a, It runs and fails a bunch of tests I don't have (this is just a newly-created CRA so it should have just one), for example,

  ● main export › should export propName from root

    ENOENT: no such file or directory, stat '/Users/aztecrex/Working/demo-create-react-app-yarn-problem/propName.js'

      at Object.fs.statSync (fs.js:907:18)
      at Object.it (node_modules.npm/jsx-ast-utils/__tests__/src/index-test.js:

After I uninstall watchman, the behavior goes back to the one described in this report.

@gaearon
Copy link
Contributor

gaearon commented Jan 31, 2017

I get many warnings before jest gives me the watch UI, for example

This is because of those node_modules.npm and node_modules.yarn folders which conflict. I wonder if there’s a way to disable Haste completely in open source with some config option, cc @cpojer? It’s not really useful to CRA users.

@aztecrex
Copy link
Author

Removed those dirs and the "install watchman" workaround fixes the problem. Uninstalling watchman causes it to re-occur.

@hongrich glad I tried it again

@cpojer
Copy link
Contributor

cpojer commented Feb 1, 2017

@gaearon yeah we are making some changes that should improve this situation.

@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

Going to close since this is out of our control.
If you have issues with Yarn please report them, and use npm while they are being fixed.

@gaearon gaearon closed this as completed Feb 11, 2017
@tsironis
Copy link
Contributor

I fixed the issue upgrading yarn to v0.20.1 and then brew install watchman. Apparently, there is a problem watching file changes in macOS Sierra.

@gaearon
Copy link
Contributor

gaearon commented Feb 20, 2017

Apparently, there is a problem watching file changes in macOS Sierra.

If your tests hang, that's not the problem described in this issue. For that problem, please see here.

@tsironis
Copy link
Contributor

Sorry my bad! I didn't describe this correctly, I meant FSWatcher is not longer available in macOS Sierra so watchman is required.

@bholtbholt
Copy link

I hit this issue today on macOS High Sierra using Yarn. Deleting my node_modules and rerunning yarn fixed it for me.

@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants