-
-
Notifications
You must be signed in to change notification settings - Fork 638
[WIP] handle errors happen in rsc payload #1663
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
[WIP] handle errors happen in rsc payload #1663
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
c676342 to
266acae
Compare
ed1170b to
59b0f0d
Compare
f2242c4 to
a761735
Compare
7133c56 to
838a6e7
Compare
4e89e93 to
07fb03e
Compare
1f3e921 to
999312d
Compare
07fb03e to
84b5cb5
Compare
999312d to
aeaeca4
Compare
2405c2c to
e1fdfc7
Compare
aeaeca4 to
58fd819
Compare
01fe6ab to
767fefc
Compare
- Add `dev_server_url` helper to centralize dev server URL construction - Add `public_output_uri_path` to get relative webpack output path - Add `asset_uri_from_packer` to handle asset URIs consistently - Update `react_client_manifest_file_path` to return dev server URLs when appropriate - Add comprehensive specs for new asset URI handling This change ensures client manifest paths are properly resolved to dev server URLs during development, improving hot-reloading functionality.
eb73bef to
411207c
Compare
ba38c98
into
abanoubghadban/pro425/hydrate-components-immediately-after-downloading-chunks
* hydrate the component immediately when loaded and registered * auto register server components and immediately hydrate stores * move react-server-dom-webpack.d.ts to types directory * ensure to initialize registered stores array before accessing * refactor registration callback into separate class * make the early hydration compatible with turbopack, backward compatible and refactor * pass rsc path to RSC Client Root and move the config to RORP * update min node version to 18 * export registerServerComponent as a separate entrypoint to avoid client bundle increase * Update webpack assets status checker to use server bundle configuration * Update webpack assets status checker to handle bundle file paths * [WIP] handle errors happen in rsc payload (#1663) * stream rsc payload in json objects like streamed react components * make path to rsc bundle and react client manifest configurable * feat: Improve client manifest path handling for dev server - Add `dev_server_url` helper to centralize dev server URL construction - Add `public_output_uri_path` to get relative webpack output path - Add `asset_uri_from_packer` to handle asset URIs consistently - Update `react_client_manifest_file_path` to return dev server URLs when appropriate - Add comprehensive specs for new asset URI handling This change ensures client manifest paths are properly resolved to dev server URLs during development, improving hot-reloading functionality. * fix: normalize RSC URL path by absorbing leading/trailing slashes * specify Shakapacker as top-level module * add tests for RSCClientRoot * Make RSCClientRoot tests run with react 18 * Update webpack asset path configuration for client manifest --------- Co-authored-by: Judah Meek <[email protected]>
* hydrate the component immediately when loaded and registered * auto register server components and immediately hydrate stores * move react-server-dom-webpack.d.ts to types directory * ensure to initialize registered stores array before accessing * refactor registration callback into separate class * make the early hydration compatible with turbopack, backward compatible and refactor * pass rsc path to RSC Client Root and move the config to RORP * update min node version to 18 * export registerServerComponent as a separate entrypoint to avoid client bundle increase * Update webpack assets status checker to use server bundle configuration * Update webpack assets status checker to handle bundle file paths * [WIP] handle errors happen in rsc payload (#1663) * stream rsc payload in json objects like streamed react components * make path to rsc bundle and react client manifest configurable * feat: Improve client manifest path handling for dev server - Add `dev_server_url` helper to centralize dev server URL construction - Add `public_output_uri_path` to get relative webpack output path - Add `asset_uri_from_packer` to handle asset URIs consistently - Update `react_client_manifest_file_path` to return dev server URLs when appropriate - Add comprehensive specs for new asset URI handling This change ensures client manifest paths are properly resolved to dev server URLs during development, improving hot-reloading functionality. * fix: normalize RSC URL path by absorbing leading/trailing slashes * specify Shakapacker as top-level module * add tests for RSCClientRoot * Make RSCClientRoot tests run with react 18 * Update webpack asset path configuration for client manifest --------- Co-authored-by: Judah Meek <[email protected]>
* hydrate the component immediately when loaded and registered * auto register server components and immediately hydrate stores * move react-server-dom-webpack.d.ts to types directory * ensure to initialize registered stores array before accessing * refactor registration callback into separate class * make the early hydration compatible with turbopack, backward compatible and refactor * pass rsc path to RSC Client Root and move the config to RORP * update min node version to 18 * export registerServerComponent as a separate entrypoint to avoid client bundle increase * Update webpack assets status checker to use server bundle configuration * Update webpack assets status checker to handle bundle file paths * [WIP] handle errors happen in rsc payload (#1663) * stream rsc payload in json objects like streamed react components * make path to rsc bundle and react client manifest configurable * feat: Improve client manifest path handling for dev server - Add `dev_server_url` helper to centralize dev server URL construction - Add `public_output_uri_path` to get relative webpack output path - Add `asset_uri_from_packer` to handle asset URIs consistently - Update `react_client_manifest_file_path` to return dev server URLs when appropriate - Add comprehensive specs for new asset URI handling This change ensures client manifest paths are properly resolved to dev server URLs during development, improving hot-reloading functionality. * fix: normalize RSC URL path by absorbing leading/trailing slashes * specify Shakapacker as top-level module * add tests for RSCClientRoot * Make RSCClientRoot tests run with react 18 * Update webpack asset path configuration for client manifest * Fix client startup rendering when the script runs after the page loaded * Refactor client-side rendering and page lifecycle management - Extract context and page lifecycle utilities into separate modules - Improve handling of Turbolinks and Turbo events - Simplify client startup and rendering process - Add more robust page load and unload event management - Rename and reorganize context-related functions * Add component registry timeout configuration - Introduce a new configuration option `component_registry_timeout` to control the maximum time to wait for client-side component registration - Update `CallbackRegistry` to handle timeout events and reject pending callbacks - Add validation for the timeout configuration in the Rails configuration - Modify client-side startup and page lifecycle to support the new timeout mechanism - Enhance error handling for unregistered components and stores * Refactor CallbackRegistry and clientStartup initialization - Move `initializeTimeoutEvents()` call to `getOrWaitForItem()` method in CallbackRegistry - Remove unnecessary 4-second delay in clientStartup - Clean up commented-out webpack configuration in clientWebpackConfig * Update StoreRegistry error messages for clarity * Fix RSC stream parsing to handle incomplete chunks - Introduce `lastIncompleteChunk` to preserve partial JSON data between stream reads - Ensure complete JSON chunks are processed by splitting on newlines - Handle cases where the last chunk is not terminated with a newline * Refactor CallbackRegistry to improve item tracking and usage - Introduce `ItemInfo` type to track item registration, usage, and promise details - Enhance timeout handling with more informative warnings for unused items - Improve `get`, `has`, and `getAll` methods to better track item usage - Optimize `getOrWaitForItem` to handle existing promises and registration states * Refactor CallbackRegistry and ComponentRegistry to simplify item tracking - Simplify CallbackRegistry by separating item storage and waiting promises - Introduce separate maps for registered items and waiting promises - Add a set to track unused items - Update ComponentRegistry to include a clear method - Modify test to use new clear method * Update StoreRegistry test to use clearHydratedStores method * Update RSC test to append newline to stream chunks * don't strip the html chunk * Add "use client" directive to RSCClientRoot * Convert RSCWebpackLoader to TypeScript * Comment on the need for workaround * Fix Knip * Simplify RSCWebpackLoader * remove rsc? and stream? render options and add render_mode option * Rename flight_payload_streaming to rsc_payload_streaming * Add async component retrieval and timeout handling to ComponentRegistry * add specs for packs generator * Update react_on_rails_helper_spec with new props added to component definition script * Remove webpacker dependency from Gemfile.lock * Remove unnecessary webpacker mocking in configuration spec * Update package.json exports for React Server Components * fix: don't trim html content on server * Enable prerendering by default for React Server Components * Rename RSC rendering methods and configuration to payload generation * add more comments for new components * linting * Update package.json exports order for React Server Components * remove prerender option for stream_react_component * small linting changes * Use node 16 to run oldes tests * Remove unnecessary data-store-dependencies attribute from test scripts * linting * Convert loadReactClientManifest to async and update RSC rendering * make RSCClientRoot tests compatible with React 19 * Test fetch function only with node version 18+ * pass props to RSC generator and avoid state reset on hydration * Add ignore configuration for Knip static analysis * small changes * Implement stream buffering to safely handle stream events and errors * Fix stream error emission in buffered stream * Simplify streaming result parsing logic in server rendering * remove mentions to experiment react 18 and use only react 19 * Refactor registerServerComponent into client and server modules * Add RSCWebpackPlugin for React Server Components * Replace react-server-dom-webpack with @shakacode-tools/react-on-rails-rsc * Update TypeScript configuration and package dependencies for React Server Components * Remove webpack dependency from package configuration * Update @shakacode-tools/react-on-rails-rsc dependency to latest commit * Make reactOnRailsPageLoaded async * Update configuration to enable force_load by default and modify redux_store helper * Bump version to 15.0.0-alpha.2 and update CHANGELOG * revert this: Update package to use @abanoubghadban/react-on-rails-rsc * Configure .npmrc for private GitHub package registry * Update import statements for path and fs modules in test file * Update test specs to add data-force-load attribute by default * Add null check for ReactOnRails global object in component and store loading scripts * Bump version to 15.0.0.alpha.2 * Update GitHub Actions workflows to use Shakacode Tools Packages Token * Update package to use @shakacode-tools/react-on-rails-rsc * Revert version to 14.2.0 and update CHANGELOG * Enhance server-side rendering error logging and debugging - Add full backtrace to error messages for better diagnostics - Add temporary debugging breakpoint with binding.pry * Remove temporary debugging breakpoint in server rendering * Revert gem version to 14.2.0 in Gemfile.lock * Remove backtrace from server rendering error logging * Update package to use react-on-rails-rsc package instead of the old private package * Update CHANGELOG and knip configuration - Add description for unreleased changes in CHANGELOG - Remove unused entry from knip configuration - Add jsdom as a development dependency in knip config * Change default defer behavior for generated component packs * Update test to reflect new default defer behavior for generated component packs * Update CHANGELOG and release notes for React on Rails 15.0.0 - Add comprehensive release notes for version 15.0.0 - Highlight major features: React Server Components support and improved component hydration - Document breaking changes related to component hydration and store dependencies - Summarize key improvements in component and store hydration performance * Add domNodeId support for server-side rendering identifier prefix to support multiple components in the view * Remove PR references from 15.0.0 release notes
Summary
Remove this paragraph and provide a general description of the code changes in your pull
request... were there any bugs you had fixed? If so, mention them. If
these bugs have open GitHub issues, be sure to tag them here as well,
to keep the conversation linked together.
Pull Request checklist
Remove this line after checking all the items here. If the item is not applicable to the PR, both check it out and wrap it by
~.Add the CHANGELOG entry at the top of the file.
Other Information
Remove this paragraph and mention any other important and relevant information such as benchmarks.
This change is