core(mux-relay): fix TypeError: Cannot read property 'push' of null

This commit is contained in:
Micooz 2018-07-22 17:04:08 +08:00
parent 8661293ba4
commit a1ef787309
5 changed files with 8 additions and 14 deletions

@ -241,13 +241,13 @@ export class MuxRelay extends EventEmitter {
// once connect, flush all pending frames
const frames = this._pendingFrames.get(cid);
if (frames) {
if (frames && !outbound.destroyed) {
const buffer = Buffer.concat(frames);
this._pendingFrames.delete(cid);
outbound.write(buffer);
outbound.__tracker.trace(PIPE_DECODE, buffer.length);
setImmediate(() => this.emit('_read', buffer.length));
}
this._pendingFrames.delete(cid);
};
onDataFrame = ({ cid, data }) => {

@ -12,6 +12,8 @@ class Bound extends EventEmitter {
_conn = null;
_destroyed = false;
constructor({ config, source, conn }) {
super();
this._config = config;
@ -39,6 +41,10 @@ class Bound extends EventEmitter {
return true;
}
get destroyed() {
return this._destroyed;
}
onBroadcast() {
}

@ -6,8 +6,6 @@ export class Http2Inbound extends Inbound {
_stream = null;
_destroyed = false;
constructor(props) {
super(props);
this._stream = this._conn;
@ -81,8 +79,6 @@ export class Http2Outbound extends Outbound {
_stream = null;
_destroyed = false;
get name() {
return 'h2:outbound';
}

@ -14,8 +14,6 @@ export class TcpInbound extends Inbound {
_socket = null;
_destroyed = false;
constructor(props) {
super(props);
this._socket = this._conn;
@ -147,8 +145,6 @@ export class TcpOutbound extends Outbound {
_socket = null;
_destroyed = false;
get name() {
return 'tcp:outbound';
}

@ -13,8 +13,6 @@ export class WsInbound extends Inbound {
_socket = null;
_destroyed = false;
constructor(props) {
super(props);
this._socket = this._conn;
@ -81,8 +79,6 @@ export class WsOutbound extends Outbound {
_socket = null;
_destroyed = false;
get name() {
return 'ws:outbound';
}