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

feat: enhanced error handling and a ton of bugfixes showcased in a new example app #111

Merged
merged 2 commits into from
Jan 19, 2025

Conversation

lazarv
Copy link
Owner

@lazarv lazarv commented Jan 18, 2025

This update brings significant improvements, including a brand-new Pokémon example app designed to demonstrate the framework's enhanced error handling and caching capabilities and to showcase superb performance. In addition to the example app, this PR introduces a series of crucial bug fixes, navigation improvements, and optimizations to both client-side and server-side behavior.

A new Form navigation component has been introduced to simplify navigation based on form interactions. This component allows developers to trigger navigation based on form submissions or specific input values, without requiring additional event handlers or imperative navigation logic. This enables form-driven navigation patterns where a user’s input can dictate the next page, improving declarative control over navigation behavior.

A new mechanism for controlling when client-side navigation triggers revalidation has been added. Previously, navigation could result in unnecessary revalidation of server-side rendering, even in cases where it was not required. This led to excessive network requests and performance overhead. Now, developers can explicitly define revalidation strategies, ensuring that only the relevant components are refreshed based on user interactions or navigation. This fine-grained control allows for more efficient client-side navigation while maintaining consistency.

A global error component has been introduced to standardize error handling across applications. Instead of handling errors in multiple locations with redundant logic, applications can now define a centralized error component that gracefully captures and displays errors. This ensures a consistent error experience for users while also simplifying maintenance by reducing duplicated error handling logic. This feature also enables styling unexpected error caught during server-side rendering.

Several issues related to module resolution when using npx have been addressed. Previously, certain dependencies would not resolve correctly when executed the react-server CLI via npx, causing unexpected failures when running commands that relied on specific @lazarv/react-server modules. These resolution issues have now been fixed, ensuring that executing commands via npx correctly locates and loads the necessary modules without manual intervention.

A fix has been applied to server function calls to ensure that redirect responses behave correctly. Previously, certain redirect scenarios did not properly propagate the response to the client, resulting in broken navigation flows. This has now been corrected, allowing server functions to issue redirects that are correctly handled by the client. #110

Default CORS configuration has been adjusted to address inconsistencies in handling requests across different origins. The previous implementation had cases where preflight requests were either incorrectly blocked or missing required headers. The fixed configuration usage ensures that cross-origin requests function correctly, particularly for applications interacting with APIs and remote components from different domains.

React Server Component network requests have been updated to support credential transmission. This change ensures that cookies are correctly included in all relevant RSC network requests. This improvement allows for more seamless authentication handling without requiring manual workarounds.

Support for the "use cache" directive has been extended to additional use cases. Previously, this directive was limited in scope and did not fully cover all expected scenarios, particularly when used in certain asynchronous server function calls. These fixes ensure that "use cache" now applies more broadly and reliably across different execution contexts, allowing more efficient caching behavior and reducing redundant server computations.

Several issues affecting RemoteComponent and remote rendering have been addressed. These fixes ensure that remotely loaded components behave consistently, resolving previous issues where rendering states were not properly handled. Remote rendering now correctly handles component hydration using both sync and async React Server Components, preventing unexpected behaviour.

File-system based routing has been improved to correctly apply error boundaries at the appropriate levels, particularly for route outlets. Previously, some errors were not caught at the intended boundary, causing them to propagate unintentionally. With this update, errors encountered within a specific route segment are correctly handled by the nearest applicable error boundary, ensuring better application stability and predictable error recovery.

The documentation has been updated to include details on the new APIs introduced in this release. This includes explanations of the enhanced error handling system, details on how to use the new Form navigation component, and guidelines for configuring client-side navigation revalidation. Additionally, examples have been added to clarify best practices for handling errors at different levels of an application.

Copy link

github-actions bot commented Jan 18, 2025

✅ Documentation preview deployed to: https://react-server-docs-lhjtg8s6t-lazarv-team.vercel.app

@lazarv lazarv merged commit 3c4e6bc into main Jan 19, 2025
8 checks passed
@lazarv lazarv deleted the feat/enhance-error-handling branch January 19, 2025 00:45
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.

1 participant