hard-source-webpack-plugin
hard-source-webpack-plugin copied to clipboard
Error on incremental UnhandledPromiseRejectionWarning v0.5.15
(node:47653) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RangeError: Invalid string length (node:47653) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hi. I have the same problem. The steps to reproduce are a bit random. It usually happens when my code doesn't compile then fix it, then re-insert an error then fix it, etc. After some time this happens
We have run into this quite a bit w/ webpack watcher; if we introduce a syntax error in our jsx code, webpacker-watcher spits out this error and hangs.
RangeError: Invalid string length means a string is being created that is too big (>130MB) normally from JSON.stringify or Array.join (or even '' + "). By @SebT and @stereoscott's description it sounds like an error is being serialized or written to console that may not recurse but refers to a tree of objects that refer to each other, using less memory in that shape, but being turned into a string inflate to a size big enough to cause this error.
I'll try running and intentionally inserting errors. If any of you can figure out a minimal reproduction that'd help.
I met the same issue.
It usually happens when my code doesn't compile then fix it, then re-insert an error then fix it
It would be great if we have a solution for it. thanks
I bumped into this one, and instead of a me too comment, I thought this could help (removed some paths):
(node:35617) SyntaxError: Unexpected token c in JSON at position 7
at JSON.parse (<anonymous>:null:null)
at Readable.<anonymous> (hard-source-webpack-plugin/lib/hard-source-append-serializer.js:427:43)
at emitOne (events.js:116:13)
at Readable.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Readable.push (_stream_readable.js:208:10)
at hard-source-webpack-plugin/lib/hard-source-append-serializer.js:232:13
at <anonymous>:null:null
Inside hard-source-append-serializer.js, I found a few Promises that don't catch errors. A particular one, _readTable picked my curiosity. Simply adding .catch(error => console.log(error)) lets grunt watch continue its thing. The exception UnhandledPromiseRejectionWarning still throws, and the build still fails, but now grunt will resume the watch task. Before it just hang and had to be manually shut down.
So I started adding .catch bits to every promise that didn't have them, and UnhandledPromiseRejectionWarning just went away. Now grunt simply aborts the build “due to warnings” and continues business as usual.
I know this is a little obvious: catching errors on Promises gets rid of a problem about not catching errors on Promises. But maybe this sheds some light on the issue.
Also, in our (company's) particular use case we need to run webpack via grunt, so maybe that's part of the issue. Running webpack by itself doesn't throw the warning, so it could be more of an issue for people using grunt and/or grunt-webpack.
Thanks for the hard work on the plugin, it saves us quite some time when building in CI.
I'm running into the same issue :/ have to disable the plugin until this is solved.
@MarkLyck running webpack via grunt-shell solves the problem for now, without disabling this plugin.
Simple workaround is to delete the node_modules and re-run npm install.
I have the same problem, and when I try to restart webpack, I got this error:
TypeError: Cannot read property 'indexOf' of undefined
at splitQuery (/Users/feel-joy/Code/stylewe/node_modules/loader-runner/lib/LoaderRunner.js:19:13)
at getContext (/Users/feel-joy/Code/stylewe/node_modules/loader-runner/lib/LoaderRunner.js:238:17)
at new NormalModule (/Users/feel-joy/Code/stylewe/node_modules/webpack/lib/NormalModule.js:66:18)
at Object.thaw (/Users/feel-joy/Code/stylewe/node_modules/hard-source-webpack-plugin/lib/util/serial.js:199:12)
at Object.thaw (/Users/feel-joy/Code/stylewe/node_modules/hard-source-webpack-plugin/lib/util/serial.js:216:25)
at Compiler.pluginCompat.tap (/Users/feel-joy/Code/stylewe/node_modules/hard-source-webpack-plugin/lib/TransformNormalModulePlugin.js:654:30)
at Compiler.applyPluginsWaterfall (/Users/feel-joy/Code/stylewe/node_modules/tapable/lib/Tapable.js:92:24)
at Object.exports.call (/Users/feel-joy/Code/stylewe/node_modules/hard-source-webpack-plugin/lib/util/plugin-compat.js:175:38)
at thaw (/Users/feel-joy/Code/stylewe/node_modules/hard-source-webpack-plugin/lib/SystemArchetype.js:126:29)
at fetch (/Users/feel-joy/Code/stylewe/node_modules/hard-source-webpack-plugin/lib/SystemArchetype.js:173:16)
@Feel-Joy that feels like a different problem. Perhaps you should report a different issue?
@kxpvcr Please see #issues/423
@Feel-Joy I have the same problem, I got same error:
TypeError: Cannot read property 'indexOf' of undefined
at splitQuery (/Users/user/work/moviepro-h5/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:19:14)
at getContext (/Users/user/work/moviepro-h5/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:238:17)
at new NormalModule (/Users/user/work/moviepro-h5/node_modules/[email protected]@webpack/lib/NormalModule.js:67:18)
at Object.thaw (/Users/user/work/moviepro-h5/node_modules/[email protected]@hard-source-webpack-plugin/lib/util/serial.js:200:12)
at Object.thaw (/Users/user/work/moviepro-h5/node_modules/[email protected]@hard-source-webpack-plugin/lib/util/serial.js:217:25)
at Compiler.pluginCompat.tap (/Users/user/work/moviepro-h5/node_modules/[email protected]@hard-source-webpack-plugin/lib/TransformNormalModulePlugin.js:654:30)
at Compiler.applyPluginsWaterfall (/Users/user/work/moviepro-h5/node_modules/[email protected]@tapable/lib/Tapable.js:92:24)
at Object.exports.call (/Users/user/work/moviepro-h5/node_modules/[email protected]@hard-source-webpack-plugin/lib/util/plugin-compat.js:175:38)
at thaw (/Users/user/work/moviepro-h5/node_modules/[email protected]@hard-source-webpack-plugin/lib/SystemArchetype.js:126:29)
at fetch (/Users/user/work/moviepro-h5/node_modules/[email protected]@hard-source-webpack-plugin/lib/SystemArchetype.js:173:16)
even though not a solution, I am able to recover from it by deleting the hard-source cache in node_modules
node_modules/.cache/hard-source
it will still reoccur randomly. if anyone finds a solution please share it.