webpack-dev-middleware
webpack-dev-middleware copied to clipboard
Error: EPIPE: broken pipe, write causing livereload to break on Windows
Bug report
node:events:368
throw er; // Unhandled 'error' event
^
Error: EPIPE: broken pipe, write
at Socket._write (node:internal/net:55:25)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at Socket.Writable.write (node:internal/streams/writable:334:10)
at console.value (node:internal/console/constructor:286:16)
at console.log (node:internal/console/constructor:360:26)
at (...)\node_modules\webpack-dev-middleware\dist\utils\setupHooks.js:195:17
at processTicksAndRejections (node:internal/process/task_queues:78:11)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4047,
syscall: 'write',
code: 'EPIPE'
}
Actual Behavior
Site loads fine the first time, but when a change is made to a source file and live reload is triggered, the site builds the HTML asset but hangs before it's delivered to the browser.
Expected Behavior
Changing a source file should immediately reload the browser with the updated code.
How Do We Reproduce?
Windows 10, running Node 16.13.2. The exact line where code execution stops is /dist/utils/setupHooks.js
, line 195:
console.log(printedStats);
Debugging into the console.log()
function further, execution stops here:
if (stream.listenerCount('error') === 0) {
stream.once('error', noop);
}
The first time the site loads, when it works, stream.listenerCount('error') === 0
. When a code change is detected, stream.listenerCount('error') === 1
, and execution stops at that moment.
Commenting out the line console.log(printedStats);
in /dist/utils/setupHooks.js
allows live reload to work again.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
file-loader: ^6.2.0 => 6.2.0
html-loader: ^3.1.0 => 3.1.0
html-webpack-plugin: ^5.5.0 => 5.5.0
nodemon-webpack-plugin: ^4.7.1 => 4.7.1
sass-loader: ^12.6.0 => 12.6.0
style-loader: ^3.3.1 => 3.3.1
terser-webpack-plugin: ^5.3.1 => 5.3.1
webpack: ^5.70.0 => 5.70.0
webpack-cli: ^4.9.2 => 4.9.2
webpack-dev-server: ^4.7.4 => 4.7.4
webpack-merge: ^5.8.0 => 5.8.0
Can you try to create reproducible test repo? Sounds like a bug, but commenting console.log(printedStats);
is not real fix, sounds like race condition somewhere, removing this you reduce time on output in your console and code is faster so you don't face with the problem
Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!