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.

`path.remove` sometimes throws

See original GitHub issue

We should probably address this in Babel, but I’m occasionally running into cases of path.remove() throwing error about context:

Here’s an example from trying to run Nuclide codebase through Babili:

➜  Nuclide ./scripts/dev/release_transpile.js
7 workers. 1863 files...
Error transpiling "/Users/kangax/fbsource/fbobjc/Tools/Nuclide/pkg/fb-biggrep-cli/lib/biggrep.js"
/Users/kangax/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide-node-transpiler/lib/NodeTranspiler.js:203
      throw err;
      ^

TypeError: unknown: Property consequent of ConditionalExpression expected node to be of a type ["Expression"] but instead got null
    at Object.validate (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-types/lib/definitions/index.js:109:13)
    at Object.validate (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-types/lib/index.js:511:9)
    at NodePath._replaceWith (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/replacement.js:176:7)
    at NodePath._remove (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/removal.js:58:10)
    at NodePath.remove (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/removal.js:30:8)
    at PluginPass.CallExpression (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-plugin-transform-remove-console/lib/index.js:10:16)
    at newFn (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/context.js:105:12)

I narrowed it down to a combination of simplify and remove-console plugins, but there might be something else. The source code doesn’t have anything unusual; just few expressions with console.log and console.error.

Temporary solution could be to wrap path.remove() in try/catch. Ideal one would be to find out what’s causing this and fix it in Babel.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
danezcommented, Nov 26, 2016

It seems in a lot of cases console.log cannot just simply be removed but would rather need to be replaced by something.

In the example I replaced it with undefined.

http://astexplorer.net/#/G38YR5EEES/2

0reactions
danezcommented, Nov 26, 2016

Maybe this is broken.

Interestingly if i do:

var t = () => console.log('1st');

it turns correctly into:

var t = () => void 0;
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Cannot delete directory with Directory.Delete(path, true)
I'm not surprised that the method sometimes throws, but I'm surprised to get this particular message when recursive is true. (I know the...
Read more >
Filescripting object .delete - path not found (sometimes)
This works for 99% of the folders i am trying to clear, but occasionally i get the following. Path = \\MYSERVER\images$\Zerotouch\Migration\ ...
Read more >
Path Operations - Essential Java Classes - Oracle Help Center
This method throws an exception if the file does not exist or cannot be accessed. You can catch the exception when you want...
Read more >
How to delete a file in Windows with a too long filename?
When you want to completely delete a directory and it contains long paths, robocopy does a VERY good job: mkdir empty_dir robocopy empty_dir ......
Read more >
How to delete a file in Java - Mkyong.com
1.1 The Files.delete(Path) deletes a file, returns nothing, or throws an exception if it fails. DeleteFile1.java. package ...
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