-
-
Notifications
You must be signed in to change notification settings - Fork 638
Get rid of renderRequestId and use local trackers instead of global tracking
#1745
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
Merged
Judahmeek
merged 14 commits into
master
from
abanoubghadban/pro538/fix-problem-of-not-caching-components-while-rsc-is-on
Jul 14, 2025
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
99d9f13
get rid of renderRequestId and use local trackers instead of global t…
AbanoubGhadban 95ecbf1
fix some minor issues
AbanoubGhadban 0734cc5
linting
AbanoubGhadban abdc351
Refactor RSC tests to use local request trackers and update context h…
AbanoubGhadban 19fc4a2
Increase timeout duration in AsyncContent test to improve reliability
AbanoubGhadban 521c5b3
Enhance error handling and validation in RSC-related modules
AbanoubGhadban 745753d
Refactor RSC component handling to improve payload key generation
AbanoubGhadban e8ebbc2
Remove unused export from utils.ts to clean up codebase
AbanoubGhadban 9a27142
Enhance error handling in RSC modules by introducing `extractErrorMes…
AbanoubGhadban a7deca6
Update parameter documentation in getReactServerComponent.client.ts
AbanoubGhadban 6547616
Renamed `createRSCPayloadKey` to `createServerComponentCacheKey`
AbanoubGhadban 1179f40
Revert " Renamed `createRSCPayloadKey` to `createServerComponentCache…
AbanoubGhadban 9bebfc4
Refactor RSC payload key generation to include `domNodeId`
AbanoubGhadban 92aa907
generate rsc payload key only if needed
AbanoubGhadban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| type PostSSRHook = () => void; | ||
|
|
||
| /** | ||
| * Post-SSR Hook Tracker - manages post-SSR hooks for a single request. | ||
| * | ||
| * This class provides a local alternative to the global hook management, | ||
| * allowing each request to have its own isolated hook tracker without sharing state. | ||
| * | ||
| * The tracker ensures that: | ||
| * - Hooks are executed exactly once when SSR ends | ||
| * - No hooks can be added after SSR has completed | ||
| * - Proper cleanup occurs to prevent memory leaks | ||
| */ | ||
| class PostSSRHookTracker { | ||
| private hooks: PostSSRHook[] = []; | ||
|
|
||
| private hasSSREnded = false; | ||
|
|
||
| /** | ||
| * Adds a hook to be executed when SSR ends for this request. | ||
| * | ||
| * @param hook - Function to call when SSR ends | ||
| * @throws Error if called after SSR has already ended | ||
| */ | ||
| addPostSSRHook(hook: PostSSRHook): void { | ||
| if (this.hasSSREnded) { | ||
| console.error( | ||
| 'Cannot add post-SSR hook: SSR has already ended for this request. ' + | ||
| 'Hooks must be registered before or during the SSR process.', | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| this.hooks.push(hook); | ||
| } | ||
|
|
||
| /** | ||
| * Notifies all registered hooks that SSR has ended and clears the hook list. | ||
| * This should be called exactly once when server-side rendering is complete. | ||
| * | ||
| * @throws Error if called multiple times | ||
| */ | ||
| notifySSREnd(): void { | ||
| if (this.hasSSREnded) { | ||
| console.warn('notifySSREnd() called multiple times. This may indicate a bug in the SSR lifecycle.'); | ||
| return; | ||
| } | ||
|
|
||
| this.hasSSREnded = true; | ||
|
|
||
| // Execute all hooks and handle any errors gracefully | ||
| this.hooks.forEach((hook, index) => { | ||
| try { | ||
| hook(); | ||
| } catch (error) { | ||
| console.error(`Error executing post-SSR hook ${index}:`, error); | ||
| } | ||
| }); | ||
|
|
||
| // Clear hooks to free memory | ||
| this.hooks = []; | ||
| } | ||
| } | ||
|
|
||
| export default PostSSRHookTracker; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.