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

feat(core): allow domain sharding #7061

Draft
wants to merge 3 commits into
base: next
Choose a base branch
from
Draft

feat(core): allow domain sharding #7061

wants to merge 3 commits into from

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Jul 2, 2024

Description

This is the studio integration side of sanity-io/client#860 - see that PR for rationale.
I'll rebase/change this PR to use a regular release of the client once the above is merged and released.

The implementation works like this:

  • We first configure and do the auth check/login on the unsharded domain. This ensures we have the right redirect URLs and such.
  • Once authenticated, we fetch the current user at the same time as we do a network check against the /ping route.
    • The ping route allows exposed network timing information (through a Timing-Allow-Origin header), which allows us to get the HTTP protocol used to access it.
    • If we detect HTTP2/3, we still use unsharded domains.
    • If the request used HTTP1, or we cannot determine the protocol (eg if the resource timing API is not available), we switch the client to sharded domains.

This is only enabled for customers with allowDomainSharding set to true, as well as the auth.loginMethod set to token. This is unfortunate, but we cannot get the auth cookie set on the regular project hostname propagated, so we have to use tokens. This does introduce overhead, since all requests will have preflight requests.

Note that this is a temporary workaround, while we work on a more permanent solution.

What to review

Either disable HTTP2/3 support (through browser flag or similar), or set FORCE_DOMAIN_SHARDING to true in createAuthStore and observe domain sharding behavior in staging. Setting the FORCE_DOMAIN_SHARDING flag back to false (or re-enabling HTTP2/3) and observe that it does not use domain sharding.

Testing

I realize this is missing tests. Since this is a temporary workaround, I find this acceptable for now. But if you feel strongly, shout out.

Notes for release

None. This is a silent release - we only want select customers to use this as a workaround, not a permanent solution.

Copy link

vercel bot commented Jul 2, 2024

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

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:50pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:50pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:50pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:50pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:50pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Jul 2, 2024 10:50pm

@rexxars rexxars requested a review from a team as a code owner July 2, 2024 22:44
@rexxars rexxars requested review from bjoerge and removed request for a team July 2, 2024 22:44
@rexxars rexxars marked this pull request as draft July 2, 2024 22:44
@rexxars rexxars removed the request for review from bjoerge July 2, 2024 22:44
Copy link
Contributor

github-actions bot commented Jul 2, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Jul 2, 2024

Component Testing Report Updated Jul 2, 2024 10:58 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 37s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 7s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 28s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 32s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 29s 4 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 37s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 18s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 6s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 21s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 6s 21 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 1m 22s 27 0 0

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.

1 participant