question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Haste map is sometimes missing dotfiles

See original GitHub issue

🐛 Bug Report

At Airbnb we are using jest haste map directly in some of our projects. When toggling on the useWatchman option to true, we’ve noticed that it sometimes includes dotfiles (e.g. .eslintrc.js) and sometimes does not. Removing the haste map cache and running watchman watch-del-all seems to resolve the problem. I’ve been able to reproduce this bug sometimes by restarting my machine and running the program again.

I’ve read through some issues that seem to be somewhat relevant to this problemspace:

From that last issue on watchman, I suspect we maybe need to add glob_includedotfiles somewhere, maybe in this vicinity? https://github.com/facebook/jest/blob/9ffd368330a3aa05a7db9836be44891419b0b97d/packages/jest-haste-map/src/crawlers/watchman.ts#L98-L147

Maybe here: https://github.com/facebook/jest/blob/9ffd368330a3aa05a7db9836be44891419b0b97d/packages/jest-haste-map/src/crawlers/watchman.ts#L129

To Reproduce

Steps to reproduce the behavior:

We are calling HasteMap like this:

const haste = new HasteMap({
    name: 'dependencies',
    platforms: [],
    retainAllFiles: true,
    extensions: ['js', 'ts', 'jsx', 'tsx'],
    rootDir,
    roots: options.roots,
    maxWorkers: os.cpus().length,
    dependencyExtractor: require.resolve(path.join(__dirname, 'jestDependencyExtractor')),
    useWatchman: false,
    watch: false,
    ignorePattern: options.honorGitIgnore ? createIgnorer(rootDir) : undefined,
    console: {
      ...global.console,
      warn() {},
    },
  });

Our directories contain a mix of files, and some are named .eslintrc.js.

This could also be related to our ignorePattern setting here, but the caching seems suspect.

Expected behavior

The list of files should be consistent regardless of cache state.

envinfo

  System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.2 - ~/.nvm/versions/node/v10.16.0/bin/npm
  npmPackages:
    jest: ^25.5.4 => 25.5.4 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
grostocommented, May 23, 2020

Cheers for a great bug report!

I tested and adding glob_includedotfiles: true seems to consistently retrieve dotfiles on macOS with Watchman. I will open a PR soon.

1reaction
vjprcommented, Jun 11, 2020

@lencioni sometimes includes dotfiles (e.g. .eslintrc.js) and sometimes does not.

I’ve noticed this sporadic behaviour too and I’ve seen reports of similar sporadic behaviour too in metro with react-native.

The code below would explain this behaviour I think. Depending on whether the clock is available, if glob is not used, then you are not going to get any dotfiles or dot dirs included.

const relativeRoot = fastPath.relative(rootDir, root);
const query = clocks.has(relativeRoot) // Use the `since` generator if we have a clock available
  ? {
      expression,
      fields,
      since: clocks.get(relativeRoot)
    } // Otherwise use the `glob` filter
  : {
      expression,
      fields,
      glob
    };
const response = yield cmd('query', root, query);
Read more comments on GitHub >

github_iconTop Results From Across the Web

jest-haste-map | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
How to resolve the jest-haste-map error in react-native?
Try to uninstall react-native from node_module folder using command npm uninstall react-native. and then re-install that module using command
Read more >
veQ - River Thames Conditions - Environment Agency - GOV.UK
Characteristic of partnership company, Miss universe philippines crown, ... Sevaster kudhes ghoti, Atn corp app, Combat outposts in afghanistan map!
Read more >
react native watchman - You.com | The search engine you control.
To reload the app press "r" To open developer menu press "d" jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
Read more >
mozilla-release: changeset 533541 ... - Mercurial
filter source actor lists so that missing threads no longer appear * - NOTE: ... non-replaced inline Elements will always have an empty...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found