sindresorhus / file-type

Detect the file type of a Buffer/Uint8Array/ArrayBuffer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

End of stream error when checking the file type of a pdf

eric-yuan-vanta opened this issue · comments

I was using an older version (16.x) and ran into this error. I then upgraded to latest, but ran into the same thing. Using the latest version (18.2.0), I've been getting the following error trace in my app with this pdf. Any idea what could be the cause?

{"name":"Error","stack":"Error: End-Of-Stream\n    at ReadStreamTokenizer.readBuffer (file:///node_modules/strtok3/lib/ReadStreamTokenizer.js:38:19)\n 
  at ReadStreamTokenizer.ignore (file:///node_modules/strtok3/lib/ReadStreamTokenizer.js:86:31)\n    at FileTypeParser.parse (file:///node_modules/file-type/core.js:614:4)\n    at Module.fileTypeFromStream (file:///node_modules/file-type/core.js:16:10)\n

I'm suspicious something is different about this pdf. I'm still able to view it with normal viewers though.

I guess we're reaching EOF somehow in the adobe ai check await tokenizer.ignore(1350);. Is this file missing something, or too short? Appreciate any help, thanks!

ET-test-011222-1027-434.pdf

I downgraded to 14.0.0, prior to the adobe illustrator support (14.1.0), and it works now. Looking at this again, I'm assuming this just breaks for any very short pdf file