Skip to content

[compiler] Add try/catch to safely read files during healthcheck #33098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

inject3r
Copy link

@inject3r inject3r commented May 2, 2025

Summary

This pull request improves the stability of react-compiler-healthcheck by wrapping the fs.readFile operation in a try/catch block.
It prevents the script from crashing when a file matched by the glob pattern is deleted or becomes unreadable before being read.
This ensures smoother execution, especially in large codebases with frequently changing files.

How did you test this change?

I ran the npx react-compiler-healthcheck command on several codebases, including scenarios where some files were deleted during execution.

Confirmed that:

The spinner continues running and displays warnings for unreadable files.

Valid files are still processed correctly.

The tool no longer crashes due to fs.readFile errors.

Copy link

@Hardanish-Singh Hardanish-Singh left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants