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

fix: now hydration event is being returned if revision does not exist in cache #9203

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

sjaanus
Copy link
Contributor

@sjaanus sjaanus commented Feb 4, 2025

Now when customer is coming with revision ID that does not exist in cache, we return hydration.

Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 4, 2025 10:40am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 10:40am

Copy link
Contributor

github-actions bot commented Feb 4, 2025

@sjaanus, core features have been modified in this pull request. Please review carefully!

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

],
});

const { body: rehydrationBody } = await app.request
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are sending 1, which does not exist in cache.

@@ -12,6 +12,22 @@ export class DeltaCache {
constructor(hydrationEvent: DeltaHydrationEvent, maxLength: number = 20) {
this.hydrationEvent = hydrationEvent;
this.maxLength = maxLength;

this.addBaseEventFromHydration(hydrationEvent);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is important change. Previously when we were initializing environment, we just filled hydration event. But hydration event changes in time, so we also need to add an event with same revision id as base event to event queue.

This way if customer got hydration with rev 100, and hydration now moves to 101, customer is coming back with 100, we need to have reference to 100.

const delta = this.delta[environment];
if (
requiredRevisionId === 0 ||
delta.isMissingRevision(requiredRevisionId)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If delta is missing revision, return hydration.

Copy link
Contributor

@FredrikOseberg FredrikOseberg left a comment

Choose a reason for hiding this comment

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

LGTM

@sjaanus sjaanus merged commit d8a47ce into main Feb 4, 2025
12 checks passed
@sjaanus sjaanus deleted the fix-hydration branch February 4, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants