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: prevent key value store from firing setKey for each open subscri… #5997

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

cngonzalez
Copy link
Member

Description

The KeyValueStore used to emit a setKey event (setting off a PUT call to the backend) for every open subscription. This means we could fire off 3-4 PUT calls for the same key in quick succession. To keep state tidy and make this scalable, I've added a shareReplay function here, which we use in other parts of the studio (especially stores in the resource cache). I've seen no ill effects or stale data, so I think it's a decent solution.

What to review

Any gotchas with this approach, or any other negative side effects I may be missing.

Testing

There are e2e tests for this branch, but no tests specifically for this case. I can add additional tests in the refactor PR for e2e tests.

@cngonzalez cngonzalez requested a review from a team as a code owner March 13, 2024 21:18
@cngonzalez cngonzalez requested review from bjoerge and removed request for a team March 13, 2024 21:18
Copy link

vercel bot commented Mar 13, 2024

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Mar 13, 2024 9:28pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 13, 2024 9:28pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2024 9:28pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Mar 13, 2024

Component Testing Report Updated Mar 13, 2024 9:33 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 38s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 31s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 59s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 1s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 11s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 19s 9 0 0

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Great catch, and great solution!

@cngonzalez cngonzalez merged commit 5482b8e into feat/fetch-settings-from-backend Mar 14, 2024
32 of 35 checks passed
@cngonzalez cngonzalez deleted the fix/simplify-kv-store branch March 14, 2024 13:16
github-merge-queue bot pushed a commit that referenced this pull request Mar 14, 2024
* feat(core): fetch structure tool settings from backend (#5901)

* feat(core): store recent search history in backend (#5940)

* feat(core): fetch inspect mode from backend (#5938)

* chore: update studio version for production-ready cellar (#5993)

* fix: prevent key value store from firing setKey for each open subscription (#5997)

* fix: update tests to match api (#6000)

* fix: update tests to match api

* fix: comment out flaky tests for now

* chore: remove unused resolve logic
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