client icon indicating copy to clipboard operation
client copied to clipboard

Client hangs if blockContent contains empty span

Open isaac-jordan opened this issue 1 year ago • 1 comments

Hi there, this JS client seems to hang if there are "text": "" spans in the response from Sanity API. The HTTP endpoint returns the below JSON fine, but the JS client with the same query will hang indefinitely (even if I set a timeout).

It seems like something in the client's processing of responses is hanging forever in some circumstances.

If I change the content in the manager, then the client will start working again.

It often seems worse if it's blank lines under an H1 tag? But I've seen it happen in a few different circumstances. Currently it makes the client pretty much unuseable for me.

Response from HTTP API:

{
    "ms": 6,
    "query": "*[_type == \"post\"]",
    "result": [
        {
            "_createdAt": "2022-11-09T20:13:54Z",
            "_id": "e3d30547-8ee0-42d5-b409-3cf52a208ebc",
            "_rev": "UckHRufVFepji8vDPE9wNu",
            "_type": "post",
            "_updatedAt": "2022-11-09T22:12:57Z",
            "author": {
                "_ref": "ef72f677-3ad6-4975-b4e9-3c585731fb83",
                "_type": "reference"
            },
            "body": [
                {
                    "_key": "aff5062c1d62",
                    "_type": "block",
                    "children": [
                        {
                            "_key": "290029bb1ffc",
                            "_type": "span",
                            "marks": [],
                            "text": "Normal text"
                        }
                    ],
                    "markDefs": [],
                    "style": "normal"
                },
                {
                    "_key": "8d3b960961df",
                    "_type": "block",
                    "children": [
                        {
                            "_key": "3ad547385583",
                            "_type": "span",
                            "marks": [],
                            "text": "H1 text"
                        }
                    ],
                    "markDefs": [],
                    "style": "h1"
                },
                {
                    "_key": "faac7482a0a3",
                    "_type": "block",
                    "children": [
                        {
                            "_key": "dc73e2904a1e",
                            "_type": "span",
                            "marks": [],
                            "text": "Normal text"
                        }
                    ],
                    "markDefs": [],
                    "style": "normal"
                },
                {
                    "_key": "269046411e24",
                    "_type": "block",
                    "children": [
                        {
                            "_key": "8d18d6bdc5d6",
                            "_type": "span",
                            "marks": [],
                            "text": ""
                        }
                    ],
                    "markDefs": [],
                    "style": "normal"
                },
                {
                    "_key": "7dc460534a6a",
                    "_type": "block",
                    "children": [
                        {
                            "_key": "bd15635cc1ca",
                            "_type": "span",
                            "marks": [],
                            "text": ""
                        }
                    ],
                    "markDefs": [],
                    "style": "normal"
                }
            ],
            "categories": [],
            "publishedAt": "2022-11-09T18:10:00.000Z",
            "slug": {
                "_type": "slug",
                "current": "first-post"
            },
            "title": "First Post"
        }
    ]
}

isaac-jordan avatar Nov 09 '22 22:11 isaac-jordan