-
Notifications
You must be signed in to change notification settings - Fork 4k
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
useUploadMediaFromBlobURL: Prevent duplicate uploads in StrictMode #62059
Conversation
Size Change: +169 B (+0.01%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in d75e15b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9268620337
|
Do you think we can build a temporary |
@youknowriad, I was just looking into that and now I'm unsure if that will solve our use case. The returned callback from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine.
Maybe this bug is a signal that we should be looking for a better solution than the
There isn't any other use case for createBlock( 'core/image', {
url: await uploadFile( file )
} ) Also this is another example where the block is not "headless", i.e., the |
@jsnajdr, I agree that would be a better solution. This is a known shortcoming, and there's an open discussion in #49466.
There was an issue or PR for a similar proposal, and if I recall correctly, the issue was making transformations async. I'll try to find it later and link it here for the reference. |
…ordPress#62059) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
…ordPress#62059) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
What?
PR added an extra check to the
useUploadMediaFromBlobURL
to prevent triggering the upload process multiple times in development mode.The bug was discovered via #61943.
Why?
The hook didn't account for the double effect run in the
StrictMode
; the effect can't cancel the in-flight upload via the cleanup method.P.S. The hooks should use theuseEffectEvent
hook when it ships in React.Testing Instructions
SCRIPT_DEBUG
is set to true.StrictMode
for the post editor.POST
request is triggered to upload the image.StrictMode patch
Testing Instructions for Keyboard
Same.
Screenshots or screencast
CleanShot.2024-05-28.at.15.35.18.mp4