Skip to content

fix: pass plugin-mode listen errors to the watch callback - #5787

Open
alexander-akait wants to merge 3 commits into
mainfrom
fix/plugin-listen-error
Open

alexander-akait wants to merge 3 commits into
mainfrom
fix/plugin-listen-error

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #5782

In plugin mode, a listen() failure (e.g. EADDRINUSE) was only logged from the done hook, so watch() callers never saw it and the build kept running with no server. The listen is still started once from the aggregate done, and is now awaited from each Compiler's async done hook: the compiler itself, or every child of a MultiCompiler (whose aggregate done fires inside the last child's done). The error now reaches the watch() callback and webpack stops watching, like start() rejecting.

Port already taken, compiler.watch({}, (err) => …):

single Compiler MultiCompiler
before err is null, error only logged err is null, error only logged
after err.code === "EADDRINUSE" err.code === "EADDRINUSE"

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes, test/e2e/api-plugin.test.js: "should propagate listen errors via the watch callback" for a single compiler and for a MultiCompiler, both with a real occupied port. They replace "should log a listen() failure instead of throwing", which asserted the old behavior.

Does this PR introduce a breaking change?

No. The error goes to the watch() callback instead of the logger.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a

Use of AI

Claude Code wrote the fix and the tests. It confirmed the new tests fail without the fix, and it ran test/e2e/api-plugin.test.js and npm run lint locally.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Plugin-mode server startup failures, including port conflicts, are now reported through the compiler’s watch callback instead of being logged while watching continues.
    • Shutdown now waits for pending setup and listening operations to finish.

In plugin mode the server is started from the aggregate `done` hook and a
`listen()` failure such as `EADDRINUSE` was only logged, so the watch build
kept running without a server. Await the listen from each `Compiler`'s
async `done` hook (every child of a `MultiCompiler`), so the error reaches
the `watch()` callback.

Fixes #5782

Claude-Session: https://claude.ai/code/session_013FhutSnStkMpV2mZSNb8M9
@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 36debd1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-dev-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bf454e0a-4f51-46e8-9687-6dfba90cdb24
Commits

Reviewing files that changed from the base of the PR and between 3b613f4 and 36debd1.

Files selected for processing: 1
  • test/e2e/api-plugin.test.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

In plugin mode, the server retains its setup-and-listen promise. Compiler done hooks await that promise and forward listen failures to the watch() callback. Tests cover port conflicts for single-compiler and MultiCompiler setups, and a patch changeset documents the behavior.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 36deb

Plugin listen failures are delivered through the watch callback as intended, and no merge-blocking risk is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: propagating plugin-mode listen errors to the watch callback.
Linked Issues check Passed Issue #5782 requires plugin-mode listen failures to reach the watch() callback. lib/Server.js tracks the pending listen promise and awaits it from compiler done hooks, including MultiCompiler …
Out of Scope Changes check Passed The changes stay within issue #5782. lib/Server.js implements error propagation. test/e2e/api-plugin.test.js verifies the behavior. The changeset documents the fix. No unrelated change is identifi…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #5782 requires plugin-mode listen failures to reach the watch() callback. lib/Server.js tracks the pending listen promise and awaits it from compiler done hooks, including MultiCompiler children. The end-to-end tests cover both compiler setups with an occupied port and verify EADDRINUSE in the watch callback.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #5782. lib/Server.js implements error propagation. test/e2e/api-plugin.test.js verifies the behavior. The changeset documents the fix. No unrelated change is identified.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

`api-plugin`, `event-source` and `hot-and-live-reload` all rewrote
`test/fixtures/reload-config/main.css`, and `node --test` runs files in
parallel, so a test could see another file's colour or an extra rebuild.
Give `api-plugin` and `event-source` their own copies, as `progress`
already does with `reload-config-2`.

Claude-Session: https://claude.ai/code/session_013FhutSnStkMpV2mZSNb8M9
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.82%. Comparing base (9a6472e) to head (36debd1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5787      +/-   ##
==========================================
+ Coverage   95.80%   95.82%   +0.02%     
==========================================
  Files           6        6              
  Lines        5551     5583      +32     
==========================================
+ Hits         5318     5350      +32     
  Misses        233      233              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant