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) {