Skip to content

Add error handling and directory safety for type-map generation#65

Open
sangram-2003 wants to merge 2 commits intowebpack:mainfrom
sangram-2003:main
Open

Add error handling and directory safety for type-map generation#65
sangram-2003 wants to merge 2 commits intowebpack:mainfrom
sangram-2003:main

Conversation

@sangram-2003
Copy link
Copy Markdown

Problems:
No error handling
If folder doesn’t exist → crash
If write fails → silent failure
Directory may not exist
out path might not be created yet
Blocking I/O
writeFileSync blocks event loop (not ideal in tools)

made changes in plugins/processor.mjs
The current implementation writes type-map.json using writeFileSync without ensuring the output directory exists or handling potential errors.

This may cause the process to fail if the directory is missing or if file writing encounters an issue.

This PR improves robustness by:
Ensuring the output directory exists using mkdirSync with recursive option
Wrapping file writing in a try/catch block to prevent crashes and provide meaningful error logs

@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

@avivkeller
Copy link
Copy Markdown
Member

Can you change this to ensure the out directory at the beginning of execution, and revert everything else?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change seems wrong. Why you're changing this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unrelated change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unrelated change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unrelated change.

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

Successfully merging this pull request may close these issues.

3 participants