sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
4.96k stars 390 forks source link

fix(core): add retry to image observer and loading state #6709

Closed pedrobonamin closed 1 week ago

pedrobonamin commented 2 weeks ago

Description

We have a racing condition in the BaseImageInput component, in some cases, specially with big images the fetch request to resolve the reference is happening before the reference exists. Making the image input to persist in a "loading" state which nothing indicates it. Also, there was no retry option when the reference was not properly resolved.

With this changes, a retry option is added to the observeAssetDoc function, fixing this problem. Also, a loading state was included in the image input.

How to reproduce this issue:

Reproducing the issue in next

https://github.com/sanity-io/sanity/assets/46196328/bed7456e-f5de-472a-a28c-e4d2fffdc29a

After fix

After the fix I was not able to reproduce this issue anymore.

https://github.com/sanity-io/sanity/assets/46196328/dad16eb0-6a1a-4664-875c-c12cc3a2e878

What to review

Testing

Manual testing of the issue, couldn't reproduce it.

Notes for release

vercel[bot] commented 2 weeks ago

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 1:27pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 1:27pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2024 1:27pm
1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **studio-workshop** | ⬜️ Ignored ([Inspect](https://vercel.com/sanity-io/studio-workshop/6wDnmX9diBgBdZPWAHPX8gHNZSZr)) | [Visit Preview](https://studio-workshop-git-edx-1341.sanity.build) | | May 21, 2024 1:27pm |
github-actions[bot] commented 2 weeks ago

No changes to documentation

github-actions[bot] commented 2 weeks ago

Component Testing Report Updated May 21, 2024 1:31 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 36s 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/FocusTracking.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 16s 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) 20s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 15s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 30s 12 0 0