-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Synced Pattern: A possible error when a block is unmounted #61941
Comments
Maybe you can try reproducing by switching to "text editor" or something. |
I tried, and it didn't work :/ |
I looked into this issue and found that the error occurs here.
The following changes seem to resolve the issue. diff --git a/test/e2e/specs/editor/various/patterns.spec.js b/test/e2e/specs/editor/various/patterns.spec.js
index 77f97ee300..daa962aa36 100644
--- a/test/e2e/specs/editor/various/patterns.spec.js
+++ b/test/e2e/specs/editor/various/patterns.spec.js
@@ -388,6 +388,13 @@ test.describe( 'Synced pattern', () => {
.getByRole( 'button', { name: 'Add' } )
.click();
+ // Wait until the pattern is created.
+ await editor.canvas
+ .getByRole( 'document', {
+ name: 'Block: Pattern',
+ } )
+ .waitFor();
+
await admin.createNewPost();
await editor.canvas
.getByRole( 'button', { name: 'Add default block' } ) This code also exists here: gutenberg/test/e2e/specs/editor/various/patterns.spec.js Lines 434 to 439 in 62b0efd
|
@talldan, can you reproduce the error when running the e2e test? |
Yep, I see the error when running the test 🤔 It doesn't seem anything to do with synced patterns, just that this test exploits an issue that can probably happen for any block. Here's a fix - Fix error when reloading while saving a pattern Unfortunately it then leads to another intermittent error when running this test:
I'm guessing the error can only happen when reloading, probably the code is holding on to element references that have been detached from the DOM or something as the page unloads. I agree with @t-hamano's proposed change, the test should wait for the pattern to be created. I'm not sure if playwright waits automatically for HTTP requests to be resolved before reloading, if not there's a small chance on a slow server that the pattern won't have been created in time when the page is reloaded. |
It looks like the bug is specific to the e2e test and impossible to reproduce manually. @t-hamano's solution sounds like a good fix for it. Thanks for testing everyone! |
I noticed this while inspecting warnings logged in debug mode - #61929.
The following e2e test for synced patterns triggers an error -
can be inserted after refresh
. It most likely happens when a block is unmounted due to page navigation.I can't reproduce it manually because, unlike e2e tests, the browser's DevTools console doesn't keep logs from previous pages.
Steps to reproduce
wp-env
/npm run test:e2e -- test/e2e/specs/editor/various/patterns.spec.js --ui
can be inserted after refresh
test.SCRIPT_DEBUG Patch
Screenshot
The text was updated successfully, but these errors were encountered: