Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

upload() will emit an error ECONNRESET after finish is called #704

Copy link
Copy link
@sirisian

Description

@sirisian
Issue body actions

I was doing asynchronous code in the finish handler for an upload, and I noticed that the error handler is not unregistered after finish is called. At least in node v20.15.1 this can report ECONNRESET when the socket closes.

This required that I add the following logic to my upload which is kind of annoying. Even if I'm not doing any asynchronous code the call will still output an error to my logs which is not ideal.

let ignoreErrors = false;
let writeStream = storageClient.upload({
        container,
        remote,
        headers: {
                'Access-Control-Allow-Origin': '*'
        }
}).on('error', error => {
        if (!ignoreErrors) {
                console.log(`write stream error: ${JSON.stringify(error)}`);
                reject();
        }
}).on('finish', () => {
        ignoreErrors = true;
        console.log('finished');
        // Asynchronous code before I resolve();
});
"write stream error: {\"message\":\"socket hang up\",\"stack\":\"Error: socket hang up\\n    at TLSSocket.socketOnEnd (node:_http_client:524:23)\\n    at TLSSocket.emit (node:events:531:35)\\n    at endReadableNT (node:internal/streams/readable:1696:12)\\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)\",\"code\":\"ECONNRESET\"}"}

I'd recommend disconnecting the error handler as soon as the finish is called as such errors aren't useful.

msimomni-lgtm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.