Conversation
|
Needs a test. And I'm not sure it's correct to just completely silence it. |
|
@sindresorhus do you want me to push a test that covers this scenario? |
|
Yes |
|
Just pushed the test, hope it suits the test structure. |
core.js
Outdated
| return {}; | ||
| } | ||
| }); | ||
| }).catch(() => {}); |
There was a problem hiding this comment.
I suggest to check if the error caught is an EndOfStreamError error, if not throw the error.
There was a problem hiding this comment.
Implemented as required
|
Hello @Borewit I'm encountering the same issue, but for a different reason. I'm checking the full buffer, and not a partial buffer: I have a File instance (which is a zip file in my case), and I'm just doing EndOfStreamError: End-Of-Stream
at WebStreamByobReader.read (file:///home/jmarcou/dev/my-project/node_modules/strtok3/lib/stream/AbstractStreamReader.js:26:19)
at ReadStreamTokenizer.readBuffer (file:///home/jmarcou/dev/my-project/node_modules/strtok3/lib/ReadStreamTokenizer.js:34:51)
at ReadStreamTokenizer.readToken (file:///home/jmarcou/dev/my-project/node_modules/strtok3/lib/AbstractTokenizer.js:32:32)
at ZipHandler.unzip (file:///home/jmarcou/dev/my-project/node_modules/@tokenizer/inflate/lib/index.js:127:61)
at async Object.detectConfident [as detect] (file:///home/jmarcou/dev/my-project/node_modules/file-type/core.js:521:4)
at async FileTypeParser.fromTokenizer (file:///home/jmarcou/dev/my-project/node_modules/file-type/core.js:211:21)
at async FileTypeParser.fromStream (file:///home/jmarcou/dev/my-project/node_modules/file-type/core.js:243:11)I think I'm getting this error because when it reads the last chunk of the file, the last chunk is "shorter" than the expected chunk length, and therefore it throws the EndOfStreamError. If I understand this correctly, without the error being thrown, it would have correctly returned the type as a zip. So this pull request would not only fix reading partial zip buffer, but also fix full zip buffer ^^ Could we expect to see this PR merged & release in the near future? |
|
@sindresorhus, can we merge this PR? |
Do not throw the
EndOfStreamError()exception in case you pass only partial zip data.Code to reproduce the error:
Stack trace: