nickjj / manifest-revision-webpack-plugin

Write out a manifest file containing your versioned webpack chunks and assets.
ISC License
124 stars 40 forks source link

Add error handling around the `fs.lstatSync` call #27

Closed marvinpinto closed 7 years ago

marvinpinto commented 8 years ago

Ran into an issue where the variable item.name was being set to the string template of 204 referencing for whatever reason, which resulted in the fs.lstatSync call erring out.

This PR adds some basic error handling around that call.

Sample slightly-sanitized stack trace:

111ms build modules
4ms seal
22ms optimize
10ms hashing
0ms create chunk assets
2ms additional chunk assets
1ms optimize chunk assets
0ms optimize assets
 95% emitfs.js:887
  return binding.lstat(pathModule._makeLong(path));
                 ^

Error: ENOENT: no such file or directory, lstat 'template of 204 referencing '
    at Error (native)
    at Object.fs.lstatSync (fs.js:887:18)
    at ManifestRevisionPlugin.parsedAssets (/home/marvin/projects/newproj/node_modules/manifest-revision-webpack-plugin/index.js:72:16)
    at Compiler.<anonymous> (/home/marvin/projects/newproj/node_modules/manifest-revision-webpack-plugin/index.js:160:33)
    at Compiler.applyPlugins (/home/marvin/projects/newproj/node_modules/tapable/lib/Tapable.js:26:37)
    at Watching._done (/home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:78:17)
    at Watching.<anonymous> (/home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:61:18)
    at Compiler.emitRecords (/home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:282:37)
    at Watching.<anonymous> (/home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:58:19)
    at /home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:275:11
    at Compiler.applyPluginsAsync (/home/marvin/projects/newproj/node_modules/tapable/lib/Tapable.js:60:69)
    at Compiler.afterEmit (/home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:272:8)
    at Compiler.<anonymous> (/home/marvin/projects/newproj/node_modules/webpack/lib/Compiler.js:267:14)
    at /home/marvin/projects/newproj/node_modules/async/lib/async.js:52:16
    at done (/home/marvin/projects/newproj/node_modules/async/lib/async.js:246:17)
    at /home/marvin/projects/newproj/node_modules/async/lib/async.js:44:16
    at /home/marvin/projects/newproj/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:82:15)
make: *** [build-assets] Error 1
fdanielsen commented 7 years ago

This issue is appearing for us too now with Webpack 3 and the new ModuleConcatenationPlugin, getting errors about trying to stat paths like "path/to/entry.js + 25 modules".

@nickjj and @marvinpinto, could we get progress on this? I don't think the fix proposed here is quite correct, it changes the logic quite a bit. Previously all the checks needed to pass for addCurrentItem to be set to true. Now, if it is a valid file path that's the only thing needed to pass.

If @marvinpinto don't have time to follow up on this, I could submit another pull request to try and fix this, unless @nickjj has a solution planned.

nickjj commented 7 years ago

Hi,

I haven't used Webpack 3 yet nor am I familiar with the changes it made to previous versions.

If you want to take a shot at a PR, I'd be open to it.