12:51 HTMLElement.innerText will give you the rendered text content of an element only. That means trailing unescaped whitespace is trimmed before you append each chunk when you call gptResponseElem.innerText += decoded. This will be happening regardless of how many bytes per chunk, but is most evident when your chunk size is 1, as every whitespace character is the trailing character of the element as you loop. For larger chunks there is still a chance you'll end with a whitespace character, it'll just be less frequent. To resolve, you can either use .textContent or .innerHTML instead of .innerText as both of those methods respect the raw content rather than just the rendered text.
Thank you so much for the fix and the explanation. What’s so funny is that I have a video in my backlog on “innerText vs textContent”, and I addressed this point of textContent ignoring trailing spaces or multiline spaces 😂😂😂😂 And then I forgot it while I was making this video. Maybe I should work on the video in the backlog already. But this comment was a good pointer for me so thanks again.
This is the most comprehensive tutorial someone had explained what's going behind the scene of how streaming works in Frontend and backend! Learned something new now! Keep pushing more similar content man! 💪
Fetch returns a promise => the response .json() also returns a promise => the response object in json form. A promise needs to be awaited, you can use async / await or .then. Hope that makes sense
12:51 HTMLElement.innerText will give you the rendered text content of an element only. That means trailing unescaped whitespace is trimmed before you append each chunk when you call gptResponseElem.innerText += decoded.
This will be happening regardless of how many bytes per chunk, but is most evident when your chunk size is 1, as every whitespace character is the trailing character of the element as you loop. For larger chunks there is still a chance you'll end with a whitespace character, it'll just be less frequent.
To resolve, you can either use .textContent or .innerHTML instead of .innerText as both of those methods respect the raw content rather than just the rendered text.
Thank you so much for the fix and the explanation.
What’s so funny is that I have a video in my backlog on “innerText vs textContent”, and I addressed this point of textContent ignoring trailing spaces or multiline spaces 😂😂😂😂 And then I forgot it while I was making this video.
Maybe I should work on the video in the backlog already. But this comment was a good pointer for me so thanks again.
This is the most comprehensive tutorial someone had explained what's going behind the scene of how streaming works in Frontend and backend! Learned something new now!
Keep pushing more similar content man! 💪
I'm really glad it was helpful!
This was an extraordinary video. You’re doing great work! All the very best for your channel, I hope it grows massively.
Thank you very much for the kind feedback
When I see people like deeecode I know why I haven’t gotten a job yet 🤦♂️, guy is too smart
🤣 it's just curiosity
Amazing explanation! Very simple with good examples
I'm really glad to hear that this helped
Would also like a complete react course 🙏🙏
thanks, good and informative video 👍👍
I'm really glad to hear
the status will still read 200 if the server crashed while in the middle of streaming chunks?
Yes
Yes it will read 200...you would have to catch the error in a different way...like maybe a try...catch block
Goood information 👏👏
Thanks a lot
Great informative video didnt know that
Glad you liked it
what browser are you using?
Arc
I use Arc Browser. I might switch to chrome soon tho 💀
because its in promise state ?
Fetch returns a promise => the response
.json() also returns a promise => the response object in json form.
A promise needs to be awaited, you can use async / await or .then.
Hope that makes sense
@@blissofkundaliniyoga im just answering the question why await twice the fetch api ? because its in a promise state ?
No, watch the video to understand
No, watch the video to understand
no not that...the operation is a promise, but in this video, i explained what the "operation" is
is it clear in the video?
I'm sure you enjoyed writing "decode" 😅
i actually did 😆 in preparing for the video, i thought about the joke, but while making the video, i forgot to make it
@deeecode aww 😅