const { value, done } = await reader.read();
There is this above line used in the docs (https://web.dev/serial/) to read the data coming from the serial port. Docs say that the done will turn out to be true when all of the data sent by the serial device is read. But it's not getting true and since it is in the while loop, my code is getting stuck on this line, waiting further for the serial device to send new data even though all of the data has been sent by the serial device.
(I am using Chrome browser, Windows and the code is written in js file)
I found a workaround. What I did was whenever the ReceivedData was updated with '\u0004\u0003' string, it meant that the serial device has completed the transfer of data since '\u0004\u0003' means EOTETX (End of transmission, end of text). Atleast in my case it worked since I knew the way in which the serial device wraps it's actual message within STX and EOTETX.
Refer the code below to have a proper idea of what I'm talking about. I wrote it in this way: