From 039a7b7322546a0b0c986cd9f08743b4938198cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Mon, 12 May 2025 22:06:33 +0200 Subject: [PATCH] Catch webpack failures --- src/hooks/tap-error-to-log-message.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hooks/tap-error-to-log-message.ts b/src/hooks/tap-error-to-log-message.ts index e5fcf433..ee9d633e 100644 --- a/src/hooks/tap-error-to-log-message.ts +++ b/src/hooks/tap-error-to-log-message.ts @@ -10,6 +10,17 @@ function tapErrorToLogMessage( compiler: webpack.Compiler, config: ForkTsCheckerWebpackPluginConfig ) { + + // If the webpack build fails independently from fork-ts-checker-webpack-plugin, + // it will stop the RPC server with a SIGTERM. Here we catch this case. + let webpackFailed = false; + compiler.hooks.compile.tap('ForkTsCheckerWebpackPlugin', (error) => { + webpackFailed = false; + }); + compiler.hooks.failed.tap('ForkTsCheckerWebpackPlugin', (error) => { + webpackFailed = true; + }); + const hooks = getPluginHooks(compiler); hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => { @@ -17,6 +28,10 @@ function tapErrorToLogMessage( return; } + if (webpackFailed) { + return; + } + config.logger.error(String(error)); if (error instanceof RpcExitError) {