fileTypeFromBlob should throw an error when not using Node v20
Closed this issue · 2 comments
jadesym commented
I was originally using v18.5.0 and bumped the version to v.19.4.1, which picked up the fileTypeFromBlob change that requires Nod v20. As a result, the fileTypeFromBlob call can hang on the async operation if running on Node v18, which resulted in our processing endpoints / jobs to hang, which was difficult to debug / drill down to.
Ideally the library should throw some form of error or at least an error message in this case, so it can halt the operation rather than hanging.
Borewit commented
I don't see the problem:
import { fileTypeFromBlob } from 'file-type';
import { Blob } from 'buffer'; // Node.js Blob implementation
// Print the Node.js version
console.log(`Node.js version: ${process.version}`);
// Create a Blob with GIF signature data [0x47, 0x49, 0x46]
const blob = new Blob([Buffer.from([0x47, 0x49, 0x46])]);
// Get the file type from the Blob
(async () => {
const result = await fileTypeFromBlob(blob);
console.log(JSON.stringify(result));
})();
Outputs: Node.js version: v18.5.0
Throws:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'stream' must be a byte stream. Received ReadableStream { locked: false, state: 'readable', supportsBYOB: false }
Borewit commented
As the silence procedure has concluded, I will now close this issue.