Skip to content

Metro seems to leave orphaned watchman watches frequently #814

Description

@swrobel

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Frequently, when running my app via yarn ios, the launched metro process immediately shows the following:

watchman warning:  Recrawled this watch 15 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/swrobel/Code/bakesy-apps' ; watchman watch-project '/Users/swrobel/Code/bakesy-apps'`

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
Unfortunately there doesn't seem to be an easy repro as I'm not sure what triggers these orphaned watchman processes (or at least that's my assumption of what's happening)

What is the expected behavior?
Metro avoids these situations altogether, or barring that, automatically clears the old watches and creates new ones upon startup instead of just printing this message which isn't really relevant as far as I can tell (would running watchman watch-project in a separate terminal even work correctly?)

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
yarn 1.22.18
node 16.15.0
Metro 0.67.0

metro.config.js:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

// Work around Metro bug with cjs files
// https://github.com/facebook/metro/issues/535#issuecomment-970443661
const defaultSourceExts = require('metro-config/src/defaults/defaults').sourceExts

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
  resolver: {
    sourceExts: process.env.RN_SRC_EXT
      ? [...process.env.RN_SRC_EXT.split(',').concat(defaultSourceExts), 'cjs']
      : [...defaultSourceExts, 'cjs'],
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions