Skip to content

Plugin mode: listen failure is only logged, watch build keeps running without a dev server #5782

Open

Description

@dextersealy

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 start

The 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.0

Is 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:

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);
});
});

Activity

  1. Anusha614 commented on Oct 27, 2026

    @Anusha614

    Hi! Is anyone working on this issue? I'd like to give it a try if it's available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions