Repository navigation
Plugin mode: listen failure is only logged, watch build keeps running without a dev server #5782
Description
Have you used AI?
Yes
Bug Description
When WebpackDevServer runs as a plugin in watch mode and the port is already in use, the done hook catches the listen() rejection and only logs it. The watch callback never receives an error, so the caller can't detect the failure. The process keeps rebuilding with no dev server listening.
#5739 (closing #5727) made start() reject on an occupied port, but plugin mode has no awaited call for that rejection to reach. start() with the same configuration rejects with EADDRINUSE.
Link to Minimal Reproduction and step to reproduce
https://github.com/proxy/gist.github.com/dextersealy/e39848302dfb81d7530e8d7234ec4939
Steps:
git clone https://github.com/proxy/gist.github.com/e39848302dfb81d7530e8d7234ec4939.git repro
cd repro
npm install
npm startThe output shows watch callback: no error, then the logged EADDRINUSE, then Stopping process after 5s. The process keeps running until the script stops it.
index.js occupies port 8765, then calls compiler.watch() with new WebpackDevServer({ host: 'localhost', port: 8765 }) in plugins.
Expected Behavior
The caller can detect that the dev server failed to start, as it can with start().
Actual Behavior
watch callback: no error
<e> [webpack-dev-server] Error: listen EADDRINUSE: address already in use ::1:8765
<e> at Server.setupListenHandle [as _listen2] (node:net:1941:16)
<e> at listenInCluster (node:net:1998:12)
<e> at GetAddrInfoReqWrap.callback (node:net:2207:7)
<e> at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:134:8) {
<e> code: 'EADDRINUSE',
<e> errno: -48,
<e> syscall: 'listen',
<e> address: '::1',
<e> port: 8765
<e> }
Stopping process after 5s
Environment
System:
OS: macOS 26.7.1
CPU: (12) arm64 Apple M2 Max
Memory: 626.92 MB / 64.00 GB
Binaries:
Node: 22.23.2
npm: 10.9.8
Packages:
webpack: 5.112.2
webpack-cli: 7.2.3
webpack-dev-server: 6.1.0Is this a regression?
No
Last Working Version
No response
Additional Context
In 6.0.0 the same setup crashes with an unhandled EADDRINUSE error. 6.1.0 replaces the crash with a logged error, and the process keeps running.
Still present on main:
webpack-dev-server/lib/Server.js
Lines 4590 to 4602 in d78f183
| hooks.done.tap(pluginName, () => { | |
| // `done` also fires for a one-shot `compiler.run()` build, where no | |
| // `watchRun` ran; staying passive lets that build finish and exit. | |
| if (listening || !inWatchMode || stopped) return; | |
| listening = true; | |
| listenPromise = ensureSetup() | |
| .then(() => { | |
| if (!stopped) return this.listen(); | |
| }) | |
| .catch((error) => { | |
| this.logger.error(error); | |
| }); | |
| }); |
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
Anusha614 commentedon Oct 27, 2026
Hi! Is anyone working on this issue? I'd like to give it a try if it's available.