webpack-dev-middleware: ConcurrentCompilationError: You ran Webpack twice

  • Operating System: MacOS 10.14.5 (18F203)
  • Node Version: 10.15.3
  • NPM Version: 6.4.1
  • webpack Version: 4.31.0
  • webpack-dev-middleware Version: used in webpack-dev-server

Context

docker, webpack-dev-server , lazy: true

Error itself:

ConcurrentCompilationError: You ran Webpack twice. Each instance only supports a single concurrent compilation at a time.
    at Compiler.run (/client/node_modules/webpack/lib/Compiler.js:211:37)
    at rebuild (/client/node_modules/webpack-dev-middleware/lib/context.js:81:24)
    at done (/client/node_modules/webpack-dev-middleware/lib/context.js:59:7)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:18:1)
    at AsyncSeriesHook.lazyCompileHook (/client/node_modules/tapable/lib/Hook.js:154:20)
    at emitRecords.err (/client/node_modules/webpack/lib/Compiler.js:267:22)
    at Compiler.emitRecords (/client/node_modules/webpack/lib/Compiler.js:449:39)
    at emitAssets.err (/client/node_modules/webpack/lib/Compiler.js:261:10)
    at hooks.afterEmit.callAsync.err (/client/node_modules/webpack/lib/Compiler.js:435:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/client/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/client/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/client/node_modules/webpack/lib/Compiler.js:432:27)
    at /client/node_modules/neo-async/async.js:2818:7
    at done (/client/node_modules/neo-async/async.js:3522:9)
    at MemoryFileSystem.writeFile (/client/node_modules/memory-fs/lib/MemoryFileSystem.js:328:9)
    at writeOut (/client/node_modules/webpack/lib/Compiler.js:415:30)

https://github.com/webpack/webpack/blob/master/lib/Compiler.js#L211

I still can not find the reason for this error, its very hard to catch, but found a solution:

https://github.com/notiv-nt/webpack-dev-middleware/commit/9a7ce044682aca870061f7352377c4fdc8545ff8

https://github.com/webpack/webpack-dev-middleware/blob/9f8f9471411ddf9e882f7c83c85325b5cb324216/lib/context.js#L57-L60

This code throws an error, when I reload the page during the build, sure this lines are needed?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 47 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I think i found it https://github.com/notiv-nt/webpack-dev-lazy

yarn start

open localhost:8090

open console, and paste

fetch('/bundle.js');fetch('/bundle.js');

error appears when a file is requested 2 times at the same time, but in the work, in the docker container, I cannot control requests, although only a bundle.js is requested.

The issue resolved itself by downgrading to ^3.1.14 instead of the latest version. Seems something changed in between those versions.

I don’t understand what you are saying. Your plugin crashes. What is the public folder? What are you talking about? The problem in COMPILATION

ConcurrentCompilationError: You ran Webpack twice. Each instance only supports a single concurrent compilation at a time.

Actually weirdly it was not creating

This is dev server. And this file should not be created in public

  • docker’s I/O on macos SOOOO slow

this is the problem that everything works in the “minimal version” but ill try