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

Cache shapes based only on parameters of the shape definition #1904

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

balegas
Copy link
Contributor

@balegas balegas commented Oct 29, 2024

sortedOptionsHash() uses all ShapeStreamOptions option keys, which prevents deduplication of shapes in shape cache if they have different parameters that don't belong to the shape definition.

My case is that I create a top-level shape with offset and shapeId, but in other places I don't have those parameters and I don't want to thread them through code.

What do you think?

Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 9149053
🔍 Latest deploy log https://app.netlify.com/sites/electric-next/deploys/6721171547550c000870d934
😎 Deploy Preview https://deploy-preview-1904--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

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

Ah interesting use case — yeah makes sense — within the context of an app, the shape def is what's a stable pointer to the instantiation of a ShapeStream/Shape.

This would prevent someone from creating a Shape that starts at different offsets but that's such an odd edge case that someone could just skip out of useShape at that point.

@balegas
Copy link
Contributor Author

balegas commented Oct 29, 2024

Ah interesting use case — yeah makes sense — within the context of an app, the shape def is what's a stable pointer to the instantiation of a ShapeStream/Shape.

Exactly, there are things that are specific of shape instance and not the shape definition. e.g. if you use different abort signals (I don't even know what the code will do in the case of passing an object to the stringify).

I just realised this is buggy already. If we don't want to subscribe to a shape we should never cache it.

@balegas
Copy link
Contributor Author

balegas commented Oct 29, 2024

  • need to handle deletes
  • don't cache shape if subsbribe: false

I will need this for the SSR example and I think currently it is sub-optimal. The only question is if we should include headers or not. I think yes, because of auth.

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.

2 participants