relay-compiler --watchman false option fails with FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal. when --src is current directory

Created on 17 Aug 2017  ยท  13Comments  ยท  Source: facebook/relay

Using version 1.2.0

This seems to only happen when src is the current directory: .

./node_modules/.bin/relay-compiler --src . --schema ./schema.json --watchman false                                                         Thu 17 Aug 11:11:25 2017
FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
 1: node::Abort() [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 3: v8::V8::ToLocalEmpty() [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 4: node::ReadDir(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 5: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 6: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 7: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/stevehollaar1/.nvm/versions/node/v8.4.0/bin/node]
 8: 0x3e92849840dd
fish: './node_modules/.bin/relay-compiโ€ฆ' terminated by signal SIGABRT (Abort)

Setting src to a subdirectory works as expected:

node_modules/.bin/relay-compiler --src app --schema ./schema.json --watchman false                                                1538ms ๎‚ณ Thu 17 Aug 11:14:01 2017
HINT: pass --watch to keep watching for changes.
Parsed default in 0.03s

Writing default
Writer time: 0.52s [0.43s compiling, 0.09s generating, 0.00s extra]
Unchanged: 133 files
Written default in 0.57s
wontfix

Most helpful comment

Hello, @steida,

Unfortunately, this does not looks like a bug inside my package (fast-glob).

I see that you trying to pass the following set of patterns to the fast-glob package:

[ 'components/A.js/*.+(js)',
  'components/AreYouSureConfirm.js/*.+(js)',
  // โ€ฆ
  'components/editor/*.+(js)',
  'mutations/CreateWebMutation.js/*.+(js)',
  // โ€ฆ
  'mutations/utils/*.+(js)',
  'pages/__generated__/*.+(js)',
  // โ€ฆ
  'pages/sign-in.js/*.+(js)' ]

But I see that you have the following tree on the file system:

./components/
โ”œโ”€โ”€ A.js
โ”œโ”€โ”€ AreYouSureConfirm.js
โ”œโ”€โ”€ โ€ฆ
โ”œโ”€โ”€ WebsItem.js
โ”œโ”€โ”€ __generated__
โ”‚ย ย  โ”œโ”€โ”€ โ€ฆ
โ”‚ย ย  โ””โ”€โ”€ WebsItem.graphql.js
โ”œโ”€โ”€ app
โ”‚ย ย  โ”œโ”€โ”€ โ€ฆ
โ”‚ย ย  โ””โ”€โ”€ index.js
โ”œโ”€โ”€ buttons.js
โ””โ”€โ”€ editor
    โ”œโ”€โ”€ โ€ฆ
    โ””โ”€โ”€ logReducer.js

When you pass a pattern like components/A.js/*.+(js), then you say that you want to find all files with .js extension inside the components/A.js directory.

JFYI: This is the Task that was created for your pattern:

{
  base: 'components/A.js', // The parent directory 
  dynamic: true,
  patterns: [
    'components/A.js/*.+(js)',
    '!**/node_modules',
    '!**/__mocks__',
    '!**/__tests__',
    '!**/__generated__'
  ],
  positive: [
    'components/A.js/*.+(js)'
  ],
  negative: [
    '**/node_modules',
    '**/__mocks__',
    '**/__tests__',
    '**/__generated__'
  ]
}

This issue related to wildcards inside npm scripts. Before sending the patterns to the script, they are expanded by shell. You should wrap the patterns in quotation marks:

relay-compiler --src . --include 'components/**' 'mutations/**' 'pages/**' --schema server/schema.graphql,

Or "" if you use Windows also.

After it all works fine:

[ 'components/**/*.+(js)',
  'mutations/**/*.+(js)',
  'pages/**/*.+(js)' ]

All 13 comments

I can confirm this on v1.4.1

@stevehollaar did you find a workaround for this?

I started digging a bit into this and found that readdir-enhanced which fast-glob utilizes recurses into every directory starting from src including node_modules.

The filtering as specified by exclude seems to be performed after reading everything. I suspect symlinks inside of node_modules could be the culprit but I wasn't able to pinpoint the root cause.

My current workaround for a next.js project is explicitly specifying source directories relative to src: relay-compiler --src . --include components/** --include pages/**

cc @robrichard @leebyron (#1966)

I can't think of a smart way to fix this based on @simenbrekken's observations. Any thoughts on this?

If nothing else, I think specifically showing a descriptive error message when --src === "." and the "--exclude" option is used like this could be useful (as a last resort):

You cannot use "--src ." in conjunction with the "--exclude" flag, please use "--include" instead or move your source files into a dedicated source directory"

I think this was working with node 6, but is broken now with node 8. I opened an issue in the fast-glob repo: https://github.com/mrmlnc/fast-glob/issues/23

watchman option still does not work.

@steida, what do you mean that it still doesn't work? Which version of node are you running? Did you try @simenbrekken's workaround?

Yes, I tried. Node 8.9.4. With --watchman false I get: (both locally and in circle ci)

screen shot 2018-02-28 at 00 34 26

Why is watchman needed without watching anyway? Does anybody know how to install it on circle-ci 2? Thank you.

You can check it here: https://github.com/este/este

Hello, @steida,

Unfortunately, this does not looks like a bug inside my package (fast-glob).

I see that you trying to pass the following set of patterns to the fast-glob package:

[ 'components/A.js/*.+(js)',
  'components/AreYouSureConfirm.js/*.+(js)',
  // โ€ฆ
  'components/editor/*.+(js)',
  'mutations/CreateWebMutation.js/*.+(js)',
  // โ€ฆ
  'mutations/utils/*.+(js)',
  'pages/__generated__/*.+(js)',
  // โ€ฆ
  'pages/sign-in.js/*.+(js)' ]

But I see that you have the following tree on the file system:

./components/
โ”œโ”€โ”€ A.js
โ”œโ”€โ”€ AreYouSureConfirm.js
โ”œโ”€โ”€ โ€ฆ
โ”œโ”€โ”€ WebsItem.js
โ”œโ”€โ”€ __generated__
โ”‚ย ย  โ”œโ”€โ”€ โ€ฆ
โ”‚ย ย  โ””โ”€โ”€ WebsItem.graphql.js
โ”œโ”€โ”€ app
โ”‚ย ย  โ”œโ”€โ”€ โ€ฆ
โ”‚ย ย  โ””โ”€โ”€ index.js
โ”œโ”€โ”€ buttons.js
โ””โ”€โ”€ editor
    โ”œโ”€โ”€ โ€ฆ
    โ””โ”€โ”€ logReducer.js

When you pass a pattern like components/A.js/*.+(js), then you say that you want to find all files with .js extension inside the components/A.js directory.

JFYI: This is the Task that was created for your pattern:

{
  base: 'components/A.js', // The parent directory 
  dynamic: true,
  patterns: [
    'components/A.js/*.+(js)',
    '!**/node_modules',
    '!**/__mocks__',
    '!**/__tests__',
    '!**/__generated__'
  ],
  positive: [
    'components/A.js/*.+(js)'
  ],
  negative: [
    '**/node_modules',
    '**/__mocks__',
    '**/__tests__',
    '**/__generated__'
  ]
}

This issue related to wildcards inside npm scripts. Before sending the patterns to the script, they are expanded by shell. You should wrap the patterns in quotation marks:

relay-compiler --src . --include 'components/**' 'mutations/**' 'pages/**' --schema server/schema.graphql,

Or "" if you use Windows also.

After it all works fine:

[ 'components/**/*.+(js)',
  'mutations/**/*.+(js)',
  'pages/**/*.+(js)' ]

@mrmlnc Wow, it works. Finally, :-) Thank you โค๏ธ

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings