eightshift-frontend-libs
eightshift-frontend-libs copied to clipboard
SSR blocks crash when using @wordpress/server-side-render
Describe your bug
This happens when using @wordpress/server-side-render
in Eightshift Frontend Libs blocks (code example provided below):

Notice how there are attributes in the request that weren't part of the attributes
object of the component.

This causes an error because of blockTopLevelId
- removing it from the request makes it go through, but there are still a lot of attributes in the request.

The error causes the block to crash.
This doesn't occur when using the Eightshift Frontend Libs-provided Server Side Render component, and the request doesn't include attributes we haven't explicitly added to the attributes
object this time around:

Steps to Reproduce
Failing JSX snippet when using WP Server Side Render, assuming authorMetaDateColor
and authorMetaAuthorColor
are valid attributes that are defined in the block manifest:
<ServerSideRender
block={blockFullName}
attributes={{
authorMetaDateColor,
authorMetaAuthorColor,
wrapperUse: false,
authorMetaServerSideRender: true,
}}
urlQueryArgs={{ cacheBusting: JSON.stringify(attributes) }}
/>
The same snipped works using the EFL SSR component.
Expected behavior
The WP Server Side Render component should not crash.
Screenshots, screen recording, code snippet
See above.
Environment info
PHP 7.4.29 on Valet nginx, macOS 12.3, WP 5.9.3
Please confirm that you have searched existing issues in this repo.
Yes
Please confirm that you have searched in our documentation and couldn't find the answer.
Yes
Please confirm that your bug occurs with all plugins uninstalled and with the default WordPress theme active.
No