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

Unhandled 'error' event with Connection.js #103

Open
wdanxna opened this issue Dec 26, 2018 · 1 comment
Open

Unhandled 'error' event with Connection.js #103

wdanxna opened this issue Dec 26, 2018 · 1 comment

Comments

@wdanxna
Copy link

wdanxna commented Dec 26, 2018

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:66:16)
Emitted 'error' event at:
    at Connection._handleError (/Users/drakedan/Documents/tupu/TPOverseer/node_modules/adbkit/lib/adb/connection.js:99:12)
    at Socket.<anonymous> (/Users/drakedan/Documents/tupu/TPOverseer/node_modules/adbkit/lib/adb/connection.js:53:22)
    at Socket.emit (events.js:194:15)
    at errorOrDestroy (internal/streams/destroy.js:98:12)
    at onwriteError (_stream_writable.js:436:5)
    at onwrite (_stream_writable.js:461:5)
    at _destroy (internal/streams/destroy.js:40:7)
    at Socket._destroy (net.js:620:3)
    at Socket.destroy (internal/streams/destroy.js:32:8)
    at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:67:12)

Im still trying to figure out why an error emitted by connection could be "unhandled" because the only place where Connection were created is at client.js:

 Client.prototype.connection = function() {
    var conn, connectListener, errorListener, resolver;
    resolver = Promise.defer();
    conn = new Connection(this.options).on('error', errorListener = function(err) {
      return resolver.reject(err);
    }).on('connect', connectListener = function() {
      return resolver.resolve(conn);
    }).connect();
    return resolver.promise["finally"](function() {
      conn.removeListener('error', errorListener);
      return conn.removeListener('connect', connectListener);
    });
  };

and there is an .on('error') . so what Im missing here? pease help.

@wdanxna
Copy link
Author

wdanxna commented Jan 28, 2019

hey guys, I managed to solve this issue. the reason for the error Unhandled error at: Error: write EPIPE occurs is because the Connection object is shared and its error listener was removed once client done with connecting. but error event could still be emitted after connection is established. you can reproduce this bug like this:

  1. create a sync service;

  2. start pushing some file using sync.pushFile

  3. cutting off device network before the pushing complete.

then you probably get an unhandled error. the way I solve this is add _this.connection.on('error', ...) inside sync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant