Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error ERR_STREAM_ALREADY_FINISHED shown when downloading file #827

Closed
aertms opened this issue Nov 9, 2021 · 1 comment · Fixed by #838
Closed

Error ERR_STREAM_ALREADY_FINISHED shown when downloading file #827

aertms opened this issue Nov 9, 2021 · 1 comment · Fixed by #838
Labels

Comments

@aertms
Copy link

aertms commented Nov 9, 2021

I'm having an issue:

Hello, first of all thanks for this great package!
I'm using it in an application and I have a question. I'm currently using the Meteor-Files package, version 2.0.1 with Meteor 2.4. Dev environment is Linux but it also happens in production on Heroku. I use the package in combination with S3. I think it's a server issue, it occurs with both Chrome and Firefox.

Every time I download a file the following appears in the server log:

I20211109-09:21:18.647(1)? [FilesCollection] [download(/cdn/storage/files/BpkKd89fEe8zgEC9z/original/BpkKd89fEe8zgEC9z.odt, original)]
I20211109-09:21:18.888(1)? [FilesCollection] [serve(assets/app/uploads/files/BpkKd89fEe8zgEC9z.odt, original)] [200]
I20211109-09:21:18.889(1)? [FilesCollection] [serve(assets/app/uploads/files/BpkKd89fEe8zgEC9z.odt, original)] [respond] [closeStreamCb] Error: Error [ERR_STREAM_ALREADY_FINISHED] [ERR_STREAM_ALREADY_FINISHED]: Cannot call end after a stream was finished
I20211109-09:21:18.890(1)?     at PassThrough.Writable.end (internal/streams/writable.js:585:11)
I20211109-09:21:18.891(1)?     at closeStream (packages/ostrio:files/server.js:1840:20)
I20211109-09:21:18.892(1)?     at PassThrough.<anonymous> (packages/ostrio:files/server.js:1873:9)
I20211109-09:21:18.892(1)?     at PassThrough.emit (events.js:412:35)
I20211109-09:21:18.893(1)?     at PassThrough.emit (domain.js:470:12)
I20211109-09:21:18.893(1)?     at endReadableNT (internal/streams/readable.js:1317:12)
I20211109-09:21:18.893(1)?     at processTicksAndRejections (internal/process/task_queues.js:82:21) {
I20211109-09:21:18.894(1)?   code: 'ERR_STREAM_ALREADY_FINISHED'
I20211109-09:21:18.894(1)? }
I20211109-09:21:18.894(1)? [FilesCollection] [serve(assets/app/uploads/files/BpkKd89fEe8zgEC9z.odt, original)] [respond] [closeStreamCb] Error: Error [ERR_STREAM_ALREADY_FINISHED] [ERR_STREAM_ALREADY_FINISHED]: Cannot call end after a stream was finished
I20211109-09:21:18.895(1)?     at PassThrough.Writable.end (internal/streams/writable.js:585:11)
I20211109-09:21:18.895(1)?     at ServerResponse.closeStream (packages/ostrio:files/server.js:1840:20)
I20211109-09:21:18.896(1)?     at ServerResponse.emit (events.js:400:28)
I20211109-09:21:18.896(1)?     at ServerResponse.emit (domain.js:470:12)
I20211109-09:21:18.896(1)?     at emitCloseNT (_http_server.js:817:8)
I20211109-09:21:18.897(1)?     at processTicksAndRejections (internal/process/task_queues.js:81:21) {
I20211109-09:21:18.897(1)?   code: 'ERR_STREAM_ALREADY_FINISHED'
I20211109-09:21:18.897(1)? }

The download works normally but there's this error message. Is this a problem, maybe it leads to corrupt files (so far I haven't seen any though)? Is it an implementation error on my side? Or can I just ignore it?

@polygonwood
Copy link

I'm observing the same issue, so far I have not seen anything going wrong, so it looks more like an async issue ... Nobody seems to be maintaining this actively anymore, I copied this in local package to do some maintenance (like changes required due to Mongo 5).

@dr-dimitru dr-dimitru added the bug label Jun 8, 2022
dr-dimitru added a commit that referenced this issue Jun 8, 2022
dr-dimitru added a commit that referenced this issue Jun 9, 2022
__Major changes:__

- ⚠️ `FSName` now sanitized and limited to 28 symbols, no white-spaces allowed
- ⚠️ `fileId` now sanitized and limited to 20 symbols, no white-spaces allowed
- ⚠️ File extension now sanitized and limited to 20 symbols, no white-spaces allowed
- 📦 Decouple `fs-extra`, use native node.js `fs` module
- 👨‍💻 Add missing `isData` helper via #795, by @harryadel

__Changes:__

- 👷‍♂️ Fix: #827, thanks to @aertms
- 👷‍♂️ Fix: #832, thanks to @polygonwood
- 👷‍♂️ Fix: #813, thanks to @Prinzhorn
- 👨‍💻 Fix: #834, thanks to @bladerunner2020
- 📔 Fix: #803, thanks to @bartenra
- 🏗 Sanitize inputs (`FSName`, `fileId`, `extension`) to avoid command injection
- 📔 Improved documentation, special thanks to @Prinzhorn and @make-github-pseudonymous-again
- 📔 GridFS documentation fix: #818
- 👷‍♂️ Utilize `Meteor._debug` where possible instead of `console.log`

__Other:__

- 🤝 Compatibility with `meteor@2.7.3`
@dr-dimitru dr-dimitru mentioned this issue Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants