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

ECONNRESET emitted twice #1945

Closed
mathiask88 opened this issue Dec 4, 2015 · 1 comment
Closed

ECONNRESET emitted twice #1945

mathiask88 opened this issue Dec 4, 2015 · 1 comment
Labels

Comments

@mathiask88
Copy link

I have a request like this:

progress(request(options))
    .on('progress', function(state) {
      ...
    })
    .on('error', function(err) {
      ...
    })
    .on('data', function(data) {
      hasher.update(data);
    })
    .on('abort', function() {
      ...
    })
    .pipe(unzipper)
    .on('error', function(err) {
      ...
    })
    .pipe(writeStream)
    .on('error', function(err) {
      ...
    })
    .on('finish', function() {
      ...
    });
  });

and if I stop the server while downloading a file from a HTTPS URL an ECONNRESET error is emitted twice. Here is a stack trace for both

Error: read ECONNRESET
Trace
    at Request.<anonymous> (###.js:81:15)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at Request.onRequestError (...\node_modules\request\request.js:820:8)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at TLSSocket.socketErrorListener (_http_client.js:259:9)
    at emitOne (events.js:82:20)
    at TLSSocket.emit (events.js:169:7)
    at emitErrorNT (net.js:1253:8)
Error: read ECONNRESET
Trace
    at Request.<anonymous> (###.js:81:15)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at Request.onRequestError (...\node_modules\request\request.js:820:8)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at TLSSocket.connectionErrorHandler (...\node_modules\request\request.js:81:25)
    at TLSSocket.g (events.js:260:16)
    at emitOne (events.js:82:20)
    at TLSSocket.emit (events.js:169:7)

Is this intended behavior?

And why does the pipe not end on error? Altough calling this.end() explicitly in the first error listener does not lead to the finish event. (Not a streaming expert)
Edit: I learned that the stream unpipes on error so that the end() does not propagate.

@stale
Copy link

stale bot commented Nov 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2018
@stale stale bot closed this as completed Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant