The compression algorithm in the JS function generateAndSaveUF2 doesn't support the ROM size that isn't a multiple of 1024 bytes.
This is the likely cause of the problem with N64 240p test suite ROM that I reported before whose size is 6421760 bytes = 6271.25 KiB.
The generateAndSaveUF2 calculates the number of chunks as num_chunks = Math.floor(rom.fileSize / chunk_size) where chunk_size = 1024 so it doesn't handle the last incomplete chunk in any way.