Skip to content

Commit

Permalink
fix(cli): display the error which is thrown by the plugin during the …
Browse files Browse the repository at this point in the history
…starting of `rspack serve` (#8244)
  • Loading branch information
LingyuCoder authored Oct 28, 2024
1 parent df8ca34 commit a901d54
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/rspack-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export class RspackCLI {
this.getLogger().error(e.message);
process.exit(2);
} else if (e instanceof Error) {
callback?.(e);
if (typeof callback === "function") {
callback(e);
} else {
this.getLogger().error(e);
}
return null;
}
throw e;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
mode: "development",
devtool: false,
plugins: [
{
name: "test-plugin",
apply(compiler) {
throw new Error("error in plugin");
}
}
],
devServer: {}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { normalizeStderr, runWatch } from "../../utils/test-utils";

describe("should display plugin error", () => {
it("display error", async () => {
const { stderr } = await runWatch(__dirname, ["serve"], {
killString: /Error: /
});

expect(normalizeStderr(stderr)).toContain("error in plugin");
});
});

2 comments on commit a901d54

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-10-28 0db8b94) Current Change
10000_development-mode + exec 2.13 s ± 34 ms 2.14 s ± 46 ms +0.55 %
10000_development-mode_hmr + exec 674 ms ± 22 ms 674 ms ± 17 ms -0.01 %
10000_production-mode + exec 2.7 s ± 47 ms 2.72 s ± 36 ms +0.91 %
arco-pro_development-mode + exec 1.78 s ± 72 ms 1.78 s ± 75 ms -0.01 %
arco-pro_development-mode_hmr + exec 428 ms ± 2.2 ms 429 ms ± 5.3 ms +0.35 %
arco-pro_production-mode + exec 3.21 s ± 53 ms 3.19 s ± 89 ms -0.75 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.22 s ± 58 ms 3.31 s ± 69 ms +2.93 %
threejs_development-mode_10x + exec 1.62 s ± 22 ms 1.61 s ± 13 ms -0.16 %
threejs_development-mode_10x_hmr + exec 759 ms ± 9.9 ms 769 ms ± 4.6 ms +1.21 %
threejs_production-mode_10x + exec 5.01 s ± 29 ms 5.03 s ± 33 ms +0.29 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ✅ success
examples ✅ success
devserver ✅ success

Please sign in to comment.