http fetch reset not recognized in javascript

The following JavaScript code sends a file to an embedded LWIP HTTP server in chunks.

As can be seen in the Wireshark trace, a reset sometimes occurs during transmission. In this case, the request is aborted, however the script does not receive any information from this and returns true even in case of an error.

Does anyone have a tip on how to teach the script to recognize such an error?

The function should only return true if the request was successful, otherwise the call will repeated again with the same chunk.

reset while http post

async function uploadChunk(chunk) {
  let result = false;
  const formData = new FormData();
  formData.append("file", chunk);
  sleep(10);
  
  try {
    const response = await fetch("http://" + target_ip + "/update", {
      method: "POST",
      mode: "no-cors",
      body: formData
    });
    res = await response;
    const ok_string = "OK";
    result = (response.ok & (response.statusText === ok_string));
    console.log(res);
  } catch (error) {
    console.error("Failed to upload chunk: ", error);
  }
  
  return result;
}