| 1667 | // * error is not undefined/null |
| 1668 | // * session is closed and there are no more pending or open streams |
| 1669 | [kMaybeDestroy](error) { |
| 1670 | if (error == null) { |
| 1671 | const handle = this[kHandle]; |
| 1672 | const hasPendingData = !!handle && handle.hasPendingData(); |
| 1673 | const state = this[kState]; |
| 1674 | // Do not destroy if we're not closed and there are pending/open streams |
| 1675 | if (!this.closed || |
| 1676 | state.streams.size > 0 || |
| 1677 | state.pendingStreams.size > 0 || hasPendingData) { |
| 1678 | return; |
| 1679 | } |
| 1680 | } |
| 1681 | this.destroy(error); |
| 1682 | } |
| 1683 | |
| 1684 | _onTimeout() { |
| 1685 | callTimeout(this, this); |