Skip to content

fix(core): send asynchronous warnings to the socketServer#6671

Merged
chenjiahan merged 5 commits intoweb-infra-dev:mainfrom
zalishchuk:fix-socketserver-warn
Dec 1, 2025
Merged

fix(core): send asynchronous warnings to the socketServer#6671
chenjiahan merged 5 commits intoweb-infra-dev:mainfrom
zalishchuk:fix-socketserver-warn

Conversation

@zalishchuk
Copy link
Copy Markdown
Contributor

@zalishchuk zalishchuk commented Nov 30, 2025

Summary

While migrating a project from CRA to Rsbuild, I noticed an unexpected change that didn't occur six months ago. Create React App uses ForkTsCheckerWarningWebpackPlugin to adjust the severity of issues during development, changing them from error to warning. This is helpful because it prevents the error overlay from appearing in development. Previously, this behavior worked as expected until the release https://github.com/web-infra-dev/rsbuild/releases/tag/v1.5.14. After that update, warnings still show in the terminal but are no longer sent to the browser's development server.

I tried to fix it, but I'm not sure if it's the best approach. Code deduplication can be achieved. However, after https://github.com/web-infra-dev/rsbuild/releases/tag/v1.5.14, the behavior might not be as expected, since it no longer displays warnings as it did before.

I also noticed that warnings sometimes show up in the browser console, but this happens unpredictably and for reasons that aren't clear.

class TsCheckerWarningRspackPlugin {
  apply(compiler: Rspack.Compiler) {
    new TsCheckerRspackPlugin().apply(compiler);
    const hooks = TsCheckerRspackPlugin.getCompilerHooks(compiler);
    hooks.issues.tap('TsCheckerWarningRspackPlugin', issues => {
      return issues.map(issue => ({ ...issue, severity: 'warning' }));
    });
  }
}

v1.6.10 w/o fix:

image

v1.6.10 w/ fix:

image

Related Links

https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/ForkTsCheckerWarningWebpackPlugin.js

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 30, 2025 20:01
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 30, 2025

CLA assistant check
All committers have signed the CLA.

@netlify
Copy link
Copy Markdown

netlify bot commented Nov 30, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit c208aa0
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/692d05d763687800080edb43
😎 Deploy Preview https://deploy-preview-6671--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 83 (🟢 up 20 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@zalishchuk zalishchuk changed the title feat(core): send asynchronous warnings to the socketServer fix(core): send asynchronous warnings to the socketServer Nov 30, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where asynchronous TypeScript warnings from the TypeScript checker plugin were not being sent to the browser's development server after v1.5.14. The implementation adds support for tracking and sending warnings in the same way errors are handled, restoring the behavior similar to Create React App where TypeScript issues can be downgraded from errors to warnings during development.

Key Changes:

  • Added a new sendWarning method to SocketServer for sending warnings to the client
  • Extended the async TypeScript issue handling to track and process warnings alongside errors
  • Updated comments to reflect the dual handling of errors and warnings

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/core/src/server/socketServer.ts Adds sendWarning public method to send warning messages to connected clients
packages/core/src/server/assets-middleware/index.ts Extends async TypeScript issue detection to track warnings count, filter TS warnings, and send them to the client when no errors are present

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@chenjiahan chenjiahan enabled auto-merge (squash) December 1, 2025 03:20
@chenjiahan chenjiahan merged commit 1c17090 into web-infra-dev:main Dec 1, 2025
11 checks passed
@zalishchuk
Copy link
Copy Markdown
Contributor Author

@chenjiahan, thank you for your rstackjs/ts-checker-rspack-plugin#53
It really simplifies things by eliminating the need to create a plugin warning wrapper

@chenjiahan
Copy link
Copy Markdown
Member

Thank you! It is a simple feature, but I am happy to hear it makes things easier.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants