Gutenberg: ServerSideRender component should debounce the request

Created on 15 Jun 2018  路  5Comments  路  Source: WordPress/gutenberg

Describe the bug
When using the new ServerSideRender component if you have a text control in the Inspector on each change event it sends a request to the Block API Endpoint without debouncing it. Also if one of your attributes is an array or an array of arrays or an array of objects it is not getting sent correctly to the REST API.

To Reproduce
Steps to reproduce the behavior:

  1. Use the component that is found at this gist: https://gist.github.com/ivanlopez/3f415d805704e950a94ad62a4dd75981
  2. After you install and add the component to the editor open your dev tools to the network tab in your browser.
  3. Start typing in the text field in the inspector and you'll see that every change event fires a request to the Block API endpoint without debouncing or canceling the previous request.
  4. Click on the buttons in the Inspector and you'll see that the response you get is not what you would expect. For a simple array you'll get the an array with a single value of all the items you sent. For nested array you will get all the items in one nested array. Finally for an array of objects the data is getting sent as [object Object]so the API can't process that request.

Expected behavior
I would expect that when using ServerSideRender request would get debounced. I would also expect that if you have an attribute with an array or an array of arrays or an array of objects that the ServerSideRender component would send the data correctly to the block API endpoint.

Screenshots
serversiderenderingtextcontrol

screen shot 2018-06-15 at 10 38 05 am

Desktop (please complete the following information):

  • OS: MacOS High Sierra
  • Browser Chrome
  • Version 66.0.3359.181

Additional context

  • Gutenberg 3.0.1
[Package] Server Side Render [Type] Bug

Most helpful comment

Picking this up.

All 5 comments

Also if one of your attributes is an array or an array of arrays or an array of objects it is not getting sent correctly to the REST API.

This is covered by #7086

This can cause server issues, especially with changing TextControls being passed to SSR (because those are likely to change in quick succession as you type). Sort of a mini-DDOS, most applicable if you're on bad hosting.

Use-case with RangeControl mentioned in #10168.

This can cause server issues, especially with changing TextControls being passed to SSR (because those are likely to change in quick succession as you type). Sort of a mini-DDOS, most applicable if you're on bad hosting.

Yeah, I saw this on a client project yesterday.

Picking this up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmadawais picture ahmadawais  路  271Comments

mtias picture mtias  路  83Comments

melchoyce picture melchoyce  路  169Comments

mapk picture mapk  路  80Comments

jasmussen picture jasmussen  路  173Comments