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

Emit close event when stream is complete #2976

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Conversation

driannaude
Copy link
Contributor

Fixes #2897
Fixes #2898

@lovell
Copy link
Owner

lovell commented Nov 16, 2021

Thank you very much for the PR. Are you able to add a couple of unit tests to cover this logic? This should help prevent any future regression.

@driannaude
Copy link
Contributor Author

Sure thing! I'll take a look over the next couple of days when I get a chance.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0002%) to 99.904% when pulling f952e45 on driannaude:master into 079bd7b on lovell:main.

@lovell lovell merged commit a06b8c2 into lovell:main Nov 17, 2021
@lovell lovell added this to the v0.30.0 milestone Nov 17, 2021
@lovell
Copy link
Owner

lovell commented Nov 17, 2021

Brilliant, thank you Drian!

lovell added a commit that referenced this pull request Nov 17, 2021
Y2zz pushed a commit to Y2zz/sharp that referenced this pull request Feb 26, 2022
Y2zz pushed a commit to Y2zz/sharp that referenced this pull request Feb 26, 2022
@arsonik
Copy link

arsonik commented Mar 14, 2022

Hey guys !
good job on the bug fix
But any idea on getting rid of this error though ?
(that was probably working because of the bug 🙈)

    private async handlePicture(resource: FileUpload, hash: string): Promise<MediaInformation> {
        const transformer = sharp().rotate().jpeg();
        await this.upload(resource.createReadStream().pipe(transformer), redacted({ hash, type: MediaType.Picture }));
    private upload(resource: Options['params']['Body'], name: string) {
        return new Upload({
            client: S3Snap,
            params: {
                Bucket: awsSnapConfig.bucket,
                Key: name,
                Body: resource,
            },
        })

ERROR

Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at new NodeError (node:internal/errors:372:5)
    at Sharp.onclose (node:internal/streams/end-of-stream:136:30)
    at Sharp.emit (node:events:527:28)
    at Sharp.emit (node:domain:475:12)
    at Object.<anonymous> (node_modules/sharp/lib/output.js:1139:16)
    at Object.topLevelDomainCallback (node:domain:152:15)
    at Object.callbackTrampoline (node:internal/async_hooks:128:24)

@lovell
Copy link
Owner

lovell commented Mar 14, 2022

@arsonik If you still require help, please open a new question at https://github.com/lovell/sharp/issues/new?labels=question&template=question.md - please remember that you'll need to remove non-sharp dependencies from your question, including removing any possible networking problems, as part of this.

Repository owner locked and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output stream is not properly ended after .clone() Stream is not properly ended on file -> stream
4 participants