diff-dom-streaming icon indicating copy to clipboard operation
diff-dom-streaming copied to clipboard

random bug depending chunks

Open aralroca opened this issue 1 year ago • 4 comments

There is an error according to the HTML chunks that are received. I see that when it happens, the lastNodeAdded is the same node that the end of the next chunk:

Screenshot 2024-08-09 at 16 39 43

In this case, the img node looks created but the next chunk starts with </img>.

Same here:

Screenshot 2024-08-09 at 19 00 56

The type-form custom element looks created but the next chunk has the closing tag of type-form. In this case is not displaying the slot of type-form because it comes on the next chunk together with the closing tag of type-form.

aralroca avatar Aug 09 '24 14:08 aralroca

I get a 404 trying to see the images

danielart avatar Aug 09 '24 16:08 danielart

I get a 404 trying to see the images

Thanks @danielart , updated

aralroca avatar Aug 09 '24 17:08 aralroca

the problem is in the diffing, it makes the diffing of the element when the next chunk that completes the content of the element hasn't arrived yet, so the diffing is incorrect and it leaves parts. The problem with this bug is that it is random because the browsers process the streaming chunks each time with a different size, maybe by setting an await it can be played, I was looking to see if I could find a way to play it in the test. The tests of this library are in playwright to use the behavior of the browsers.

aralroca avatar Aug 09 '24 17:08 aralroca

Probably we can assume it's closed if the parser opens an element outside it

aralroca avatar Aug 10 '24 07:08 aralroca

posible solution

When detecting the last node of the chunk it is better to implement it in a different way, the implementation with the attribute does not work and it is the one that makes the mismanagement resulting in this bug. Suggestion of proposal for this detection: look if it has no more nextSibling, neither it nor its parents and it has not yet finished streaming, then it means that it is the last node of a chunk.

aralroca avatar Sep 07 '24 14:09 aralroca