diff options
inpage - automatic dapp reload
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/local-message-stream.js | 8 | ||||
-rw-r--r-- | app/scripts/lib/port-stream.js | 4 | ||||
-rw-r--r-- | app/scripts/lib/stream-utils.js | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/app/scripts/lib/local-message-stream.js b/app/scripts/lib/local-message-stream.js index 42d193e04..76fedd9df 100644 --- a/app/scripts/lib/local-message-stream.js +++ b/app/scripts/lib/local-message-stream.js @@ -23,7 +23,7 @@ function LocalMessageDuplexStream(opts){ LocalMessageDuplexStream.prototype._onMessage = function(event){ var msg = event.data - // console.log('LocalMessageDuplexStream ('+this._name+') - heard message...') + // console.log('LocalMessageDuplexStream ('+this._name+') - heard message...', event) // validate message if (event.origin !== location.origin) return //console.log('LocalMessageDuplexStream ('+this._name+') - rejected - (event.origin !== location.origin) ') if (typeof msg !== 'object') return //console.log('LocalMessageDuplexStream ('+this._name+') - rejected - (typeof msg !== "object") ') @@ -31,7 +31,11 @@ LocalMessageDuplexStream.prototype._onMessage = function(event){ if (!msg.data) return //console.log('LocalMessageDuplexStream ('+this._name+') - rejected - (!msg.data) ') // console.log('LocalMessageDuplexStream ('+this._name+') - accepted', msg.data) // forward message - this.push(msg.data) + try { + this.push(msg.data) + } catch(err) { + this.emit('error', err) + } } // stream plumbing diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js index a6c974d6d..2644741fc 100644 --- a/app/scripts/lib/port-stream.js +++ b/app/scripts/lib/port-stream.js @@ -31,7 +31,8 @@ PortDuplexStream.prototype._onMessage = function(msg){ PortDuplexStream.prototype._onDisconnect = function(){ try { - this.end() + // this.end() + this.emit('close') } catch(err){ this.emit('error', err) } @@ -54,6 +55,7 @@ PortDuplexStream.prototype._write = function(msg, encoding, cb){ } cb() } catch(err){ + console.error(err) // this.emit('error', err) cb(new Error('PortDuplexStream - disconnected')) } diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js index fd4417d94..ca245ca9a 100644 --- a/app/scripts/lib/stream-utils.js +++ b/app/scripts/lib/stream-utils.js @@ -27,7 +27,6 @@ function setupMultiplex(connectionStream){ connectionStream.pipe(mx).pipe(connectionStream) mx.on('error', function(err) { console.error(err) - // connectionStream.destroy() }) connectionStream.on('error', function(err) { console.error(err) |