(cb)
| 732 | } |
| 733 | |
| 734 | end(cb) { |
| 735 | this._ending = true |
| 736 | |
| 737 | // if we have never connected, then end is a noop, callback immediately |
| 738 | if (!this.connection._connecting || this._ended) { |
| 739 | if (cb) { |
| 740 | cb() |
| 741 | return |
| 742 | } else { |
| 743 | return this._Promise.resolve() |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | if (this._getActiveQuery() || !this._queryable) { |
| 748 | // if we have an active query we need to force a disconnect |
| 749 | // on the socket - otherwise a hung query could block end forever |
| 750 | this.connection.stream.destroy() |
| 751 | } else { |
| 752 | this.connection.end() |
| 753 | } |
| 754 | |
| 755 | if (cb) { |
| 756 | this.connection.once('end', cb) |
| 757 | } else { |
| 758 | return new this._Promise((resolve) => { |
| 759 | this.connection.once('end', resolve) |
| 760 | }) |
| 761 | } |
| 762 | } |
| 763 | get queryQueue() { |
| 764 | queryQueueDeprecationNotice() |
| 765 | return this._queryQueue |
no test coverage detected