Skip to content
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

fix : Deprecated Methods and Improve Error Handling in fossify.js #35425

Open
NawazTalha opened this issue Mar 7, 2025 · 0 comments
Open

fix : Deprecated Methods and Improve Error Handling in fossify.js #35425

NawazTalha opened this issue Mar 7, 2025 · 0 comments

Comments

@NawazTalha
Copy link

Bug Report: Fix Deprecated Methods and Improve Error Handling in fossify.js

Description

The fossify.js script currently has a few issues that need to be addressed:

  1. Deprecated fs.rmdir Usage

    • fs.rmdir is deprecated in Node.js 14+ and should be replaced with fs.rm for better compatibility.
    • Fix: Replace fs.rmdir with fs.rm.
  2. Lack of Error Handling for fs.unlink

    • If ./apps/meteor/startRocketChat.ts does not exist, fs.unlink will throw an error, stopping the script.
    • Fix: Use fs.access to check if the file exists before attempting to delete it.
  3. Lack of Error Handling for fs.rename

    • If ./apps/meteor/startRocketChatFOSS.ts does not exist, fs.rename will fail and crash the script.
    • Fix: Wrap fs.rename in a try-catch block and provide a proper error message.
  4. Unclear Error Handling in fossify()

    • The current error handling uses if (!e), which may not properly catch all cases.
    • Fix: Instead of a generic "Unknown error", log the error properly using console.error(e.message).

Steps to Reproduce

  1. Run the script in an environment where ./ee or ./apps/meteor/ee does not exist.
  2. If ./apps/meteor/startRocketChat.ts is missing, the script will crash when fs.unlink is called.
  3. If ./apps/meteor/startRocketChatFOSS.ts is missing, the script will fail at fs.rename.

Expected Behavior

  • The script should handle missing files and directories gracefully without crashing.
  • Deprecation warnings should be removed by using fs.rm instead of fs.rmdir.

I have already submitted a pull request. Kindly do not work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant