Skip to content

Conversation

@gavande1
Copy link
Contributor

@gavande1 gavande1 commented Dec 30, 2025

Related issues

Proposed Changes

  • Added error handling in handleSiteNameChange to catch ENAMETOOLONG errors and display a user-friendly error message when site name is too long
  • Added tests to verify ENAMETOOLONG error handling works correctly
  • The renderer now gracefully handles long site names instead of crashing

Testing Instructions

  1. Open the "Add site" modal
  2. Enter a very long site name (e.g., a string of 300+ characters)
  3. Verify that instead of crashing, a user-friendly error message is displayed: "The site name is too long. Please choose a shorter site name."
  4. Run the test suite: npm test -- src/hooks/tests/use-add-site.test.tsx
  5. Verify all tests pass, including the new ENAMETOOLONG error handling tests

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

- Add error handling in handleSiteNameChange to catch ENAMETOOLONG errors
- Display user-friendly error message when site name is too long
- Add tests to verify ENAMETOOLONG error handling

Fixes STU-1182
@gavande1 gavande1 self-assigned this Dec 30, 2025
@gavande1 gavande1 requested a review from a team December 30, 2025 10:05
@wpmobilebot
Copy link

wpmobilebot commented Dec 30, 2025

📊 Performance Test Results

Comparing 34e6d43 vs trunk

site-editor

Metric trunk 34e6d43 Diff Change
load 6317.00 ms 7367.00 ms +1050.00 ms 🔴 16.6%

site-startup

Metric trunk 34e6d43 Diff Change
siteCreation 9070.00 ms 9073.00 ms +3.00 ms 🔴 0.0%
siteStartup 3951.00 ms 3957.00 ms +6.00 ms 🔴 0.2%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@gavande1 gavande1 changed the title Fix renderer crash for long site names when creating new site (STU-1182) Fix renderer crash for long site names when creating new site Dec 30, 2025
@gavande1 gavande1 changed the title Fix renderer crash for long site names when creating new site Site Creation: Fix renderer crash for long site names when creating new site Dec 30, 2025
Copy link
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

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

LGTM and works as expected 👍
Screenshot 2025-12-30 at 13 29 40

)
);
return;
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

As the exception can be thrown by generateProposedSitePath, it would be clearer to wrap only this part with try/catch.

However, in generateProposedSitePath, we already catch the underlying exception and set returned props accordingly, so we could consider moving exception handling there.

Copy link
Contributor Author

@gavande1 gavande1 Dec 31, 2025

Choose a reason for hiding this comment

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

Initially, My first approach was to handle exceptions in generateProposedSitePath. However, the main issue was with the error message. If we handle the exception in IPC handlers, it prefixes the following error message.

Error invoking remote method 'generateProposedSitePath'

if we want to remove this prefix, I would need to add an additional parameter, such as isError, to indicate that there was a problem. However, I believe this is unnecessary.

CleanShot 2025-12-31 at 14 07 53@2x

Copy link
Contributor

Choose a reason for hiding this comment

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

What if we handled the exception there, returned isNameTooLong prop, and set the error in the renderer process? It would be consistent with current error handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. To make it consistent we can do that. I will update the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 34e6d43!

- Move ENAMETOOLONG error handling to generateProposedSitePath IPC handler
- Simplify hook to display error message from IPC handler
- Update tests to reflect the change

Addresses feedback from code review
@gavande1 gavande1 requested review from nightnei and wojtekn January 1, 2026 06:01
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.

5 participants