Repository navigation
fix: pass plugin-mode listen errors to the watch callback - #5787
alexander-akait wants to merge 3 commits into
Conversation
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 detectedLatest commit: 36debd1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
No actionable comments were generated in the recent review.
|
`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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Summary
Fixes #5782
In plugin mode, a
listen()failure (e.g.EADDRINUSE) was only logged from thedonehook, sowatch()callers never saw it and the build kept running with no server. The listen is still started once from the aggregatedone, and is now awaited from eachCompiler's asyncdonehook: the compiler itself, or every child of aMultiCompiler(whose aggregatedonefires inside the last child'sdone). The error now reaches thewatch()callback and webpack stops watching, likestart()rejecting.Port already taken,
compiler.watch({}, (err) => …):CompilerMultiCompilererrisnull, error only loggederrisnull, error only loggederr.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 aMultiCompiler, 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.jsandnpm run lintlocally.Generated by Claude Code
Summary by CodeRabbit