I’m using generatepress + generateblocks to build a site and whenever I use certain scripts in custom html blocks I get a “Updating failed. The response is not a valid JSON response.” error that prevents me from saving/updating the page.
i tested your code using a HTML Block within and without using GenerateBlocks and it seems to work fine.
There are quite a few reported issues of that error on wp.org just recently. A lot of users found its permalink related. Try hitting the Save button a couple of times in Settings > Permalinks and setting it to a plain format.