I'm glad it is working now. Discarding all data received prior to the first newline is actually something the developer of the Arduino IDE 2.x plotter implemented intentionally:
// when the serial is real fast, the first line can be incomplete and contain incomplete messages
// so we need to discard it and start aggregating from the first encountered separator
let joinMessages = messages.join("");
if (discardFirstLine) {
separatorRegex.lastIndex = 0; // Reset lastIndex to ensure match happens from beginning of string
const separatorMatch = separatorRegex.exec(joinMessages);
if (separatorMatch && separatorMatch.index > -1) {
joinMessages = joinMessages.substring(
separatorMatch.index + separatorMatch[0].length
);
discardFirstLine = false;
} else {
return {
datasetNames: [],
parsedLines: [],
};
}
}