Skip to content

Commit

Permalink
Fix handling error during disconnect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Ercolano committed Mar 13, 2018
1 parent bcb677a commit 3745125
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions device/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,11 @@ export class Client extends EventEmitter {
safeCallback(closeCallback, err, result);
};

this._disableC2D(() => {
/*Codes_SRS_NODE_DEVICE_CLIENT_16_001: [The `close` function shall call the transport's `disconnect` function if it exists.]*/
this._transport.disconnect((disconnectError, disconnectResult) => {
/*Codes_SRS_NODE_DEVICE_CLIENT_16_046: [The `close` method shall remove the listener that has been attached to the transport `disconnect` event.]*/
this._transport.removeListener('disconnect', this._disconnectHandler);
onDisconnected(disconnectError, disconnectResult);
});
/*Codes_SRS_NODE_DEVICE_CLIENT_16_046: [The `close` method shall remove the listener that has been attached to the transport `disconnect` event.]*/
this._transport.removeListener('disconnect', this._disconnectHandler);
/*Codes_SRS_NODE_DEVICE_CLIENT_16_001: [The `close` function shall call the transport's `disconnect` function if it exists.]*/
this._transport.disconnect((disconnectError, disconnectResult) => {
onDisconnected(disconnectError, disconnectResult);
});
}

Expand Down

0 comments on commit 3745125

Please sign in to comment.