webpack: WP5: Unexpected lazy element in stream

Bug report

What is the current behavior?

  1. enable persistent cache in webpack config
  2. use webpack in custom dev server

when calling webpack(config), throw error Unexpected lazy element in stream.

i found the same issue but closed. issue#11661

If the current behavior is a bug, please provide the steps to reproduce.

The error can be reproduced with the following example.

    const config = {
        name: 'cache_test',
        entry: {},
        cache: {
            type: 'filesystem'
        }
    };
    const webpackCompiler = webpack(config);
Error: Unexpected lazy element in stream
    at readU8 (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\serialization\BinaryMiddleware.js:589:11)
    at BinaryMiddleware._deserialize (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\serialization\BinaryMiddleware.js:882:20)
    at BinaryMiddleware.deserialize (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\serialization\BinaryMiddleware.js:494:15)
    at Serializer.deserialize (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\serialization\Serializer.js:41:26)
    at PackFileCacheStrategy._openPack (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\cache\PackFileCacheStrategy.js:915:5)
    at new PackFileCacheStrategy (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\cache\PackFileCacheStrategy.js:887:27)
    at WebpackOptionsApply.process (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\WebpackOptionsApply.js:561:9)
    at createCompiler (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\webpack.js:81:28)
    at E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\webpack.js:44:48
    at Array.map (<anonymous>)
    at createMultiCompiler (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\webpack.js:44:33)
    at create (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\webpack.js:118:16)
    at webpack (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\webpack.js:151:32)
    at f (E:\JavaScript\wwmngnjlogic_2\vue_dev\webpack\node_modules\webpack\lib\index.js:55:16)

What is the expected behavior? the build should execute without error

Other relevant information: webpack version: 5.30.0 Node.js version: 14.16.1 Operating System: Windows Additional tools:

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (10 by maintainers)

Most upvoted comments

Note: Also you don’t need cache-loader for webpack v5, also parallel-webpack is not compatibility with webpack v5